Mashup Code Sample - Mashup that invokes an Excel Service

 

Using the Presto Connector for Excel, you can publish Excel spreadsheets as a service into the Presto Mashup Server.  This EMML code creates a mashup that calls a service published with the Excel Connector:


<mashup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemalocation="http://www.jackbe.com/2008-03-01/EMMLSchema ../src/schemas/EMMLSpec.xsd"
        xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema" xmlns:macro="http://www.jackbe.com/2008-03-01/EMMLMacro"
        name="formatter">   <!-- Operation name -->
    <operation name="invoke">    <!-- Our only output -->
        <output name="result" type="document"></output>
        <!-- The variables being used. Notice that "datos" and "vacio" have a basic structure since they'll be used to append results -->
        <variables>
            <variable name="salio" type="document"></variable>
            <variable name="datos" type="document">
                <profesores></profesores>
            </variable>
            <variable name="vacio" type="document">
                <profesores></profesores>
            </variable>
        </variables>
        <!-- Our result being built -->
        <constructor outputvariable="result" />
        <!-- The operation that comes from the default "getData" operation that Excel Connector provides -->
        <invoke operation="getData" service="HojaExcel" outputvariable="salio"></invoke>
        <!-- We go for each item and append the info to the previous variables declared -->
        <foreach variable="item" items="$salio//item">
            <assign fromvariable="vacio" outputvariable="datos"></assign>
            <appendresult outputvariable="datos">
                <profesor_1 trato="{$item/Trato/string()}" nombrep="{$item/NombreP/string()}"></profesor_1>
            </appendresult>
            <!-- Is there more than one teacher? -->
            <if condition="$item/Column1 != '' ">
                <appendresult outputvariable="datos">
                    <profesor_2 trato="{$item/Column2/string()}" nombrep="{$item/Column2/string()}"></profesor_2>
                </appendresult>
            </if>
            <!-- Are there more than two teachers? -->
            <if condition="$item/Column14 != '' ">
                <appendresult outputvariable="datos">
                    <profesor_3 trato="{$item/Column15/string()}" nombrep="{$item/Column16/string()}"></profesor_3>
                </appendresult>
            </if>
            <!-- Final structure -->
            <appendresult outputvariable="result">
                <materia nombre="{$item/Nombre_Materia}">{$item/Periodo} {$datos/profesores}</materia>
            </appendresult>
        </foreach>
    </operation>
</mashup>

 

 

5
Your rating: None Average: 5 (1 vote)