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

RE: descendant-or-self XSLT 1.0

Subject: RE: descendant-or-self XSLT 1.0
From: cknell@xxxxxxxxxx
Date: Mon, 20 Mar 2006 08:36:56 -0500
descendant or self
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:   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

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-2013 All Rights Reserved.