[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Still thinking to object oriented...

Subject: Still thinking to object oriented...
From: "Jonas Bassl" <jonas.bassl@xxxxxxxxxxxxxx>
Date: Wed, 24 Sep 2008 09:05:31 +0200
 Still thinking to object oriented...
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.