|
Subject: RE: [xsl] descendant-or-self XSLT 1.0 From: cknell@xxxxxxxxxx Date: Mon, 20 Mar 2006 08:36:56 -0500 |
This set of templates does what you ask, but it is a bad practice to use "xml" as an element name. Since <result> may be a child of <node> or <diff>, I made a template that matches either. When I apply-templates from that template I match every <result>. The output is "123456".:
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="xml">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="node|diff">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="result">
<xsl:value-of select="." />
</xsl:template>
--
Charles Knell
cknell@xxxxxxxxxx - email
-----Original Message-----
From: news@xxxxxxxxxxx
Sent: Mon, 20 Mar 2006 14:15:26 +0100
To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: [xsl] descendant-or-self XSLT 1.0
Hello list!
I've got a xml:
<xml>
<node>
<result>1</result>
<result>2</result>
<result>3</result>
<diff>
<result>4</result>
<result>5</result>
<result>6</result>
</diff>
</node>
<node>
...
</node>
...
</xml>
I want to process all result children inside the <node> node. No matter if
they are stored inside <node/> or the descendant <diff/>. I want to handel
the <result/> nodes as one result set. So I m trying not to use two
apply-templates after another.
Example:
<xsl: template match"/">
<xsl:apply templates select="//node"/> </xsl:template>
<xsl:template match="node">
<xsl:apply-templates select="descendant-or-self::result"/>
</xsl:template>
<xsl:template match="result">
<xsl:value-of select="."/>
</xsl:template>
The output WANTED is "123456".
The output I GET is "123"
When trying:
<xsl:apply-templates select="*/result"/> I only get 456.
:(
What Xpath do I have to use in XSLT 1.0 to get ALL <result/>
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] descendant-or-self XSLT 1, G. Ken Holman | Thread | Re: [xsl] descendant-or-self XSLT 1, Keith Fahlgren |
| Re: [xsl] descendant-or-self XSLT 1, G. Ken Holman | Date | Re: [xsl] descendant-or-self XSLT 1, Keith Fahlgren |
| Month |