[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Still thinking to object oriented...
Subject: [xsl] Still thinking to object oriented... From: "Jonas Bassl" <jonas.bassl@xxxxxxxxxxxxxx> Date: Wed, 24 Sep 2008 09:05:31 +0200 |
Hallo, i have a problem to solve in XSLT and i just need help with the processing of that language. I have an XML-tree as follows: [CODE] <node1> <node2> <node3> <special_node1/> </node3> <node4> <node5> <node6> <special_node2/> </node6> </node5> </node4> </node2> </node1> [/CODE] What i have to do is, to search for every "special_node*" for printing out the name and potential attributes of that node and all his parents. This is quite easy to get. I do it like this: [CODE] <xsl:stylesheet version="2.0" ... <xsl:template match="//*"> <xsl:for-each select="//*"> <xsl:variable name="current_name" select="name(.)"/> <xsl:if test="contains(string($current_name),'Special')"> <xsl:for-each select="ancestor-or-self::node()"> <xsl:value-of select="name()"></xsl:value-of> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:template> </xsl:stylesheet> [/CODE] My problem now is, that i don't want one node to appear twice in the result list. For example in the code above, the result would be something like: node1 node2 node3 special_node1 node1 node2 node4 node5 node6 special_node2 You see that "node1" and "node2" appear twice which is right after the style sheet i wrote there. Can anyone help me now to change the style sheet that the following result would be created: node1 node2 node3 special_node1 node4 node5 node6 special_node2 Needles to say, that this example is by far not as complicated as the real XML-structures, i have to process, but i hope, you will understand the main problem. I would be really happy if someone can help my here because i am racking my brain now since days. Regards, Jonas
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Xsl:strip-space and xsl:p, Pankaj Chaturvedi | Thread | Re: [xsl] Still thinking to object , Mukul Gandhi |
Re: [xsl] Custom function in templa, Ian Stokes-Rees | Date | RE: [xsl] Xsl:strip-space and xsl:p, Michael Kay |
Month |
Keywords