xsl-list
[Top] [All Lists]

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

2006-03-20 06:28:30
At 2006-03-20 14:15 +0100, you wrote:
Hello list!

I've got a xml:
...
The output WANTED is "123456".
The output I GET is "123"

Then your processor is broken ... your templates looked correct and I used them below to get the expected answer.

When trying:
<xsl:apply-templates select="*/result"/> I only get 456.
:(

You don't say where you are in the tree when you try the above ... the above would give you "456" if your current node is <node> since <diff> satisfies the wild-card node test.

What Xpath do I have to use in XSLT 1.0 to get ALL <result/>

From where?  If from the top why not just use select="//result"?

I hope this helps.

. . . . . . .  Ken

T:\ftemp>type swisslab.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>

T:\ftemp>xslt swisslab.xml swisslab.xsl con
123456
123456
T:\ftemp>type swisslab.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:apply-templates select="//node"/>
  <xsl:text>
</xsl:text>
  <xsl:apply-templates select="//result"/>
</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>

</xsl:stylesheet>
T:\ftemp>

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--