Subject: Array like processing (Xpath 1 / XSLT 1)
Posted By: akentanaka Post Date: 7/1/2008 8:44:52 AM
I am building a new XML out of an XML.  But first, I have to perform some validation/translation routines and db read that will build the target text() node.  This extra process will "suspend" the XSLT processing so I will have to pass a number of times between XMLs to build a new XML.   It's like an array handling routine where the array is populated and read back later.  

Assuming, XML_01 contains a starting point element like  

<value/>

XML_02 will be iterated.  On each pass a new node/path is derived

First pass:

 <field name="field1">data 1</field>

Second pass:

 <field name="field2">data 2</field>

Third pass:

 <field name="field3">data 3</field>


On each pass above, XML_01 evolves into

First pass:

<value>
 <field name="field1">data 1</field>
</value>

Second pass:

<value>
 <field name="field1">data 1</field>
 <field name="field2">data 2</field>
</value>

Third pass - final:

<value>
 <field name="field1">data 1</field>
 <field name="field2">data 2</field>
 <field name="field3">data 3</field>
</value>


The reason I'm doing this is because I need to hold more than 40 or so fields and field values.  Having a token to hold all of them individually maybe too cumbersome to maintain.  

Thanks for the usual guidance!


Reply By: akentanaka Reply Date: 7/2/2008 2:22:29 AM
I will answer my own inquiry.   

Array like processing needs another xslt physically residing somewhere that needs to be imported to the one XSLT that builds the target XML.

Which is a luxury that I don't have.

So, I had to amend my validation lookup table by introducing

- use_flag if I need the field in the target XML
- mapping field
- and the node-set() instruction to find the data from the source XML

By putting the Xpath logic in the database, my XSLT code becomes simple and cleaner.









Go to topic 72447

Return to index page 1