|
next
|
Subject: Any good way to handle repeating, paired tags using XSLT? Author: Eric Dean Date: 04 Jun 2010 05:57 PM
|
I have a source XML document that has been provided to me and I have no control over it's format. It has header-level information as well as detail level information. At both the header and detail levels there are generic, paired tags used to contain data that doesn't have a place in the document.
Example:
<Header>
...Normal header-level XML structure here...
<ExtendedInfo>
<Name>Blah</Name>
<Value>Blah's Value</Value>
</ExtendedInfo>
<ExtendedInfo>
<Name>More Stuff</Name>
<Value>More Stuff's Value</Value>
</ExtendedInfo>
...ExtendedInfo continues many times...
</Header>
The problem is that there can be dozens of these "ExtendedInfo" tags. Many I don't care about but others I need to use throughout the target document. They represent completely unrelated data that would not be logically grouped together and I would use the value of the <Name> tag to determine if/how to use the data in the output.
My initial thought was to parse them all up front using a for-each, store the ones I care about in variables and use those variables later. Seems that I can't do this, however, as the variables would be out of scope.
The only way I can see to do it would be to have a for-each everywhere that I need data from one of these nodes. This would be extremely inefficient, however, as I would have to go through them all, checking the value of the <Name> node many times, everywhere that I needed data from one of these tags in the target.
Hopefully my ignorance is just causing me to miss something obvious. I'd really appreciate any help.
Thanks,
Eric
|
|
|