Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

split multi-value XML nodes

 
Edward Chalk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have xml that looks like this:

<ORDER>
<CUSTNAME>JULIAN SMITH</CUSTNAME>
<ITEMS>RICE CRISPIES,CORNFLAKES</ITEMS>
<QUANTITIES>1,2</QUANTITIES>
</ORDER>

I need an XSLT to transform this to:
<ORDER>
<CUSTNAME>JULIAN SMITH</CUSTNAME>
<ITEMS>
<ITEM>
<ITEMNAME>RICE CRISPIES</ITEMNAME>
<QUANTITY>1</QUANTITY>
</ITEM>
<ITEM>
<ITEMNAME>CORNFLAKES</ITEMNAME>
<QUANTITY>2</QUANTITY>
</ITEM>
</ITEMS>
</ORDER>

So I need to do 2 actions;
- split the CSV delimited node to multiple actions
- reassign the split values to nodes grouped by the parent ITEM

Thanks :-)
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you have posted nothing about what you have so far, I can only point you to the use of strings operation generally used to resolve such kind of problem, in particular, the use of substring-before(), substring-after() together with the use of named template and resursive template call. This is a page amongst many you may find useful:
http://www.dpawson.co.uk/xsl/sect2/N1755.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic