Samples

SamplesXml

Code

Config

API Docs

Download

Neolectric

Generating raw xml

This is similar to loop-nested.html but it generates raw xml by replacing the html table elements with other tags and changing the content type to text/xml.

<?xml version="1.0"?>  <!-- notice contentType -->
<dxp:DxpPage xmlns:dxp="dxp.neolectric.com" contentType="text/xml" buffsize="4096">

<!-- get ordersfrom roomservice table -->
<dxp:DbAction value="query" dbcon="demo" store="orders">
 <dxp:Cp name="stmt">select id, room, stamp from roomservice</dxp:Cp>
</dxp:DbAction>

<!-- get items linked to order -->
<dxp:DbAction value="query" dbcon="demo" store="items" colindex="0">
 <dxp:Cp name="stmt">select orderid, name, cost from roomitem</dxp:Cp>
</dxp:DbAction>

<!-- create an index for items on the orderid column -->
<dxp:MatrixColumnIndex value="${items}" col="0" store="items.index"/>

<roomservice>
<dxp:LoopMatrix value="${orders}" cols="0,1,2">
<order>
 <ID>${0}</ID>
 <room>${1}</room>
 <timestamp>${2}</timestamp>
 <dxp:LoopRowset value="${items}" cols="0,1,2" prefix="s" map="${items.index}" key="${0}"> 
  <item>
   <orderid>${s0}</orderid>
   <name>${s1}</name>
   <cost>${s2}</cost>
  </item> 
 </dxp:LoopRowset>
</order> 
</dxp:LoopMatrix>
</roomservice>

</dxp:DxpPage> 

Alternate layout that puts the order.ID into an attribute rather than a tag and writes a file

<dxp:WriteBytes filename="dxp/samplexml/roomorders.xml">
<roomservice>
<dxp:LoopMatrix value="${orders}" cols="0,1,2">
<order id="${0}">
 <room>${1}</room>
 <timestamp>${2}</timestamp>
 <dxp:LoopRowset value="${items}" cols="0,1,2" prefix="s" map="${items.index}" key="${0}"> 
  <item>
   <orderid>${s0}</orderid>
   <name>${s1}</name>
   <cost>${s2}</cost>
  </item> 
 </dxp:LoopRowset>
</order> 
</dxp:LoopMatrix>
</roomservice>
</dxp:WriteBytes>

NOTE: this will be raw xml without a stylesheet so you'll have to "View Page Source" in your browser to see the tags. You can use your Back button to return here.

Try it: loop-nested-xml.dxp

Alternate: loop-nested-xml2.dxp