SQL Function

Topics: General, XSLT
Sep 27, 2011 at 7:24 PM

I am trying to use my sql function values in my xslt function.

I created the sql connection to pull a record to tell me if the system is up or down.  The sql function works and give me the following output:

<root>
     <NewDataSet>
         <Table>
            <Payment_Online>Yes</Payment_Online>
            <ONLINE_ID>1</ONLINE_ID>
        </Table>
    </NewDataSet>
</root>
How can I get the value of Payment_Online in my xslt?
This is what I see in my preview (OUTPUT) in my xlst function after I added the SQL function in my Function Calls Tab:
<in:inputs xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
    <!-- Function Call Result (3 ms), XPath /in:inputs/in:result[@name='CheckSystem']/root -->
     <in:result name="CheckSystem">
         <root xmlns="">
             <NewDataSet>
                 <Table>
                    <Payment_Online>Yes</Payment_Online>
                    <ONLINE_ID>1</ONLINE_ID>
                </Table>
            </NewDataSet>
        </root>
    </in:result>
</in:inputs>

I just need to check if the Payment_Online value is "Yes" or "No" and then I can Display a offline page or the normal page.

 

Thanks

Developer
Sep 28, 2011 at 6:28 AM

Hi, c2w

You can get the value like this:

<xsl:value-of select="/in:inputs/in:result[@name='CheckSystem']/root/NewDataSet/Table/Payment_Online"/>

You can create a variable and use it in your template, e.g.

<xsl:variable name="isOnline" select="/in:inputs/in:result[@name='CheckSystem']/root/NewDataSet/Table/Payment_Online"/>
...

<xsl:choose>
<xsl:when test="$isOnline = 'Yes'">

<!-- show the normal page -->

</xsl:when>
<xsl:otherwise>

<!-- show the offline page -->

</xsl:otherwise>
</xsl:choose>

/Vitaly

 

 

Developer
Sep 28, 2011 at 6:30 AM

We have a quick guide about creating and using SQL Functions here.