midrange.com code scratchpad |
Name:
Sample XMLi Template using SQL
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
01/19/2011 12:17:49 am
|
IP:
Logged
|
|
Description:
This template uses SQL to build the XML then writes it to the IFS
|
Code:
- <xmli:template xmlns:xmli="http://www.sourceforge.net/xmli" sql-naming="SQL" format="pretty" >
-
- <!-- This example runs a SQL statement and builds XML from the results -->
-
- <root>
-
- <!-- Run SQL to get a list of Orders by order number (sql-naming is set to SQL) -->
- <xmli:run-sql name="orders" statement="select ordordno, orddat, ordtot, ordcus
- from xmlilib.xmliorders
- order by ordordno">
- </xmli:run-sql>
-
- <!-- For each row found, write the XML -->
- <!-- Note: The columns in the result set are referenced by {$statementName.ordinalPosition} -->
- <!-- Note: the OrderTotal element has a leading $ before the ordtot value. -->
- <xmli:for-each>
-
- <order>
- <OrderNumber><xmli:value-of select="orders.1" /></OrderNumber>
- <OrderDate><xmli:value-of select="orders.2" /></OrderDate>
- <OrderTotal>$<xmli:value-of select="orders.3" /></OrderTotal>
- <OrderCustomer><xmli:value-of select="orders.4" /></OrderCustomer>
- </order>
- </xmli:for-each>
- </root>
-
- <!-- The result is written to the IFS in the path specified (the path could be a parameter) -->
- <xmli:write-to-file path="'/XMLi/Examples/Results/Example12.xml'" />
-
- </xmli:template>
-
-
|
|
|