Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


xslt / xpath question

From: Brian Schroeder <spam0504@----------.-->
To: NULL
Date: 8/4/2004 8:08:00 PM
Hello Group,

I'm quite new to xml, xpath and xslt so I hope I've not overlooked a
resource where the answer to my question is.

I'll try to give a short example, but in XML everything gets bloated
really fast.

I've got the following situation:

=== a.xml ===
<?xml version="1.0" encoding="ISO-8859-1"?>
<n categorie="A">
	<n categorie="B">
		<n categorie="C"/>
	</n>
	<n categorie="D"/>
</n>
===

I want to transform this via xslt to the following

A
A->B
A->B->C
A->D

I came up with the following stylesheet

=== test.xsl ===
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="n">
    <xsl:value-of select="ancestor::*[@categorie]/attribute::categorie"/>
    -&gt; <xsl:value-of select="@categorie"/><xsl:text>
</xsl:text>
    <xsl:apply-templates select="n"/>
  </xsl:template>
</xsl:stylesheet>
===

I guess, that "ancestor::*[@categorie]/attribute::categorie" should select
all ancestor, having an attribute categorie, and from those nodes the
attribute. My problem is, that only the first attribute "A" will result
from this question. It seems, that I have to concatenate the values, but
concat did not help.

I would really appreciate help and even more pointers to some online
resource where I can learn about this kind of things. (So far, the best I
found were the w3 recommendations. Most of the other stuff seemed quite
useless.)

Thanks a lot,

Brian

-- 
Brian Schröder
http://www.brian-schroeder.de/


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent