Re: [xsl] Saxon node matching order

Subject: Re: [xsl] Saxon node matching order
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Nov 2008 10:03:28 -0500
At 2008-11-28 14:49 +0000, Ed Yau wrote:
I have a question about how Saxon chooses which node to match next.

I have some XML that looks a bit like this:

<x>
   <y>
      <z>Peter</z>
   </y>
   <z> </z>
   <y>
      <z>Jones</>
   </y>
</x>

What I'm trying to achieve is the follow:

<x>
      <z>Peter</z>
      <z> </z>
      <z>Jones</>
</x>

With the code below:

<xsl:template match="x" >
        <xsl:apply-templates select="y|z"/>
</xsl:template>

Have you considered:


<xsl:template match="x" >
        <xsl:apply-templates select=".//z"/>
</xsl:template>

... or is there some reason you need to know when you are going through <y>. You can always look from <z> to know what your parent is.

I hope this helps.

. . . . . . . Ken

--
Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
:  Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview:  http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread