I have an XSLT in which I create (from the input) intermediate variables, such as the following (hard code, but dynamic in nature):
<xsl:variable name="variableX"> <ValidCode CodePart="CP1" Code="C1"/> <ValidCode CodePart="CP2" Code="C2"/> <ValidCode CodePart="CP1" Code="C3"/> <ValidCode CodePart="CP2" Code="C4"/> <ValidCode CodePart="CP2" Code="C5"/> </xsl:variable>
I want to iterate over individual occurrences of CodePart values. In XSLT 2.0, it's easy:
<xsl:for-each select="distinct-values($variableX/ValidCode/@CodePart)">...</xsl:for-each>
But what is the best way to do this in XSLT 1.0?
Please note: I cannot use the key, since it is a dynamically defined variable, and not part of the input file.
My input file contains a list of all possible parts of the code as follows:
<root> <CodePart><value>CP1</value></CodePart> <CodePart><value>CP2</value></CodePart> <CodePart><value>CP3</value></CodePart> </root>
So, I thought about //CodePart/value over //CodePart/value , providing uniqueness for starters. But then I need some kind of Xpath expression that includes the condition
"occurs in node -set of all values ββof $ variableX / ValidCode / @ CodePart"
and use something like
<xsl:for-each select="//CodePart[..condition..]/value">...</xsl:for-each>
Is there a simple form of the Xpath expression I'm looking for?
Or is a different approach preferable?
source share