Re: [xsl] descendant-or-self XSLT 1.0

Subject: Re: [xsl] descendant-or-self XSLT 1.0
From: Keith Fahlgren <keith@xxxxxxxxxxx>
Date: Mon, 20 Mar 2006 08:53:59 -0500
On Monday 20 March 2006 8:36 am, cknell@xxxxxxxxxx wrote:
> What Xpath do I have to use in XSLT 1.0 to get ALL <result/>

If you really care about only <result> elements, why not ignore 
everything else?

The basic ignore stylesheet is this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
  <xsl:template match="*"> 
    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>

Write one stylesheet based on the element(s) you do care about:
  <xsl:template match="result">
    <xsl:value-of select="text()"/>
  </xsl:template>

Combine:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0">
  <xsl:output method="text"/>
  <!-- Ignore, but descend through every element -->
  <xsl:template match="*"> 
    <xsl:apply-templates/>
  </xsl:template>
  <!-- Except for the one I care about.. -->
  <xsl:template match="result">
    <xsl:value-of select="text()"/>
  </xsl:template>
</xsl:stylesheet>

xsltproc /work/tools/xslt/oneoff/xsl-list.xsl zoot.xml
123456


HTH,
Keith

Current Thread