Hi all,
I have got the following issue, which I do not get resolved:
I have a source XML document containing the following structure (just an extract):
Alles anzeigen
What I need to have is a unique node list, containing all systems with the same name exactly once. Therefore I created a for-each loop as follows:
Alles anzeigen
So my question is: How can I reduce the list to only have each entry seperatly and
still access to all tag values below <system>
I tried several things using preceding-sibling, etc. but it does not work. Also after sorting I could remeber the last one, but since I cannot change the value of a defined valriable, this does not work. So basically the question is when I loop through the structure ... how can I skip a a "node" which was already used in the previous loop step.
Your help is highly appreciated !!!
Thanks in advance,
Steffen
I have got the following issue, which I do not get resolved:
I have a source XML document containing the following structure (just an extract):
Quellcode
- <root>
- <records>
- <record>
- <attribA>A</attribA>
- <attribB>A</attribB>
- <attribC>A</attribC>
- <attribD>A</attribD>
- <attribE>A</attribE>
- <user>
- <id>UserA</id>
- <roles>
- <role>
- <system>
- <sysname>ABC</sysname>
- <sysattr1>A</sysattr1>
- <sysattr2>B</sysattr2>
- <sysattr3>C</sysattr3>
- </system>
- </role>
- <role>
- <system>
- <sysname>ABC</sysname>
- <sysattr1>A</sysattr1>
- <sysattr2>B</sysattr2>
- <sysattr3>C</sysattr3>
- </system>
- </role>
- <role>
- <system>
- <sysname>XYZ</sysname>
- <sysattr1>X</sysattr1>
- <sysattr2>Y</sysattr2>
- <sysattr3>Z</sysattr3>
- </system>
- </role>
- <role>
- <system>
- <sysname>DEF</sysname>
- <sysattr1>D</sysattr1>
- <sysattr2>E</sysattr2>
- <sysattr3>F</sysattr3>
- </system>
- </role>
- </roles>
- </user>
- <user>
- <id>UserB</id>
- <roles>
- <role>
- <system>
- <sysname>ABC</sysname>
- <sysattr1>A</sysattr1>
- <sysattr2>B</sysattr2>
- <sysattr3>C</sysattr3>
- </system>
- <system>
- <sysname>XYZ</sysname>
- <sysattr1>X</sysattr1>
- <sysattr2>Y</sysattr2>
- <sysattr3>Z</sysattr3>
- </system>
- </role>
- <role>
- <system>
- <sysname>DEF</sysname>
- <sysattr1>D</sysattr1>
- <sysattr2>E</sysattr2>
- <sysattr3>F</sysattr3>
- </system>
- </role>
- </roles>
- </user>
- </record>
- </records>
- </root>
What I need to have is a unique node list, containing all systems with the same name exactly once. Therefore I created a for-each loop as follows:
Quellcode
- <xsl:template match="/root/records/record">
- <xsl:for-each select="user/roles/role/system">
- <xsl:sort select="sysname" />
- <!-- Problem is, that I now get the following node list concerning "sysname":
- ABC
- ABC
- ABC
- XYZ
- XYZ
- DEF
- DEF
- But to continue with this information in another section, I want to skip
- the duplicates. Therefore I wanted to compare the current element with the
- previous one. Using preceding-sibling, following-sibling, etc. does not work.
- -->
- </xsl:for-each>
- </xsl:template>
So my question is: How can I reduce the list to only have each entry seperatly and
still access to all tag values below <system>
I tried several things using preceding-sibling, etc. but it does not work. Also after sorting I could remeber the last one, but since I cannot change the value of a defined valriable, this does not work. So basically the question is when I loop through the structure ... how can I skip a a "node" which was already used in the previous loop step.
Your help is highly appreciated !!!
Thanks in advance,
Steffen