XSLT - recursive string extraction

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi all,<br/>
<br/>
I have an XML element that has the following text value...<br/>
<br/>
2010: 451 2009: 452 2008: 482<br/>
<br/>
Basically, what this data represents is this... The value directly before the colon, is a year value, and the value after the first space after colon and before the 2nd space after the colon is the value associated with that year. So on the example above, we
have, Year: 2010, value: 451, and then, Year: 2009, value: 452 etc.<br/>
<br/>
The amount of year-value pair in the string value is unknown. If there was a maximum of three, I would be able to handle this easily stripping out all the values other than the colons to give me the count, and then use substring-before/after etc.<br/>
<br/>
I was wondering if there is a neat method I could use to extract the data and output it into the following format...<br/>
<br/>
<DataValues><br/>
<Data><br/>
<Year>2010</Year><br/>
<Value>451</Value><br/>
</Data><br/>
<Data><br/>
<Year>2009</Year><br/>
<Value>452</Value><br/>
</Data><br/>
...<br/>
</DataValues><br/>
<br/>
Thanks in advance<br/>
<br/>
Tryst
<
Tryst

View the full article
 
Back
Top