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

Re: Axis specifier questions once again

Subject: Re: Axis specifier questions once again
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 11 Nov 2009 16:01:24 -0500
Re:  Axis specifier questions once again
At 2009-11-11 13:26 -0600, a kusa wrote:
I have a nested list like this:
...
So in my transformation, the above snippet would transform as follows
with the exception of the last notes where I am having a problem:
...
Now, here is my problem. I want the <note> elements at the end of the
last <listlevel> element to come under the last step2 element.

Fine ... so you want to first process step2 without processing notes, and then you want to process the notes. I think regarding your issue this way (if I've understood you correctly) is better than trying to conceive of axis addressing as you've tried. I think you are missing the issue that the result tree is created in the order of the result tree, not in the order of the source tree.


I hope the example below helps.

. . . . . . . Ken

t:\ftemp>type akusa.xml
<list1>
<note><para>test</para></note>
  <listlevel>
  sample1
 </listlevel>

<list2>
  <listlevel>
  sample2
 </listlevel>
<list3>

  <listlevel>
sample3
 </listlevel>
</list3>

  <listlevel>
  sample4
 </listlevel>
<list3>

  <listlevel>
  sample5
 </listlevel>
</list3>
  <listlevel>
  sample6
 </listlevel>
<note><para>1 Note</para></note>
<note><para>2 Note</para></note>
<note><para>3 Note</para></note>
</list2>
</list1>
t:\ftemp>call xslt akusa.xml akusa.xsl
<?xml version="1.0" encoding="utf-8"?><step1>
<note><para>test</para></note>
  <text>
  sample1
 </text>

<step2>
  <text>
  sample2
 </text>
<step3>

  <text>
sample3
 </text>
</step3>

  <text>
  sample4
 </text>
<step3>

  <text>
  sample5
 </text>
</step3>
  <text>
  sample6
 </text>



</step2><note><para>1 Note</para></note><note><para>2 Note</para></note><note><para>3 Note</para></note>
</step1>
t:\ftemp>type akusa.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">


<xsl:template match="list1">
  <step1>
    <xsl:apply-templates/>
  </step1>
</xsl:template>

<xsl:template match="list2">
  <!--first produce the output not considering notes-->
  <step2>
    <xsl:apply-templates select="node()[not(self::note)]"/>
  </step2>
  <!--then continue the output with the notes-->
  <xsl:apply-templates select="note"/>
</xsl:template>

<xsl:template match="list3">
  <step3>
    <xsl:apply-templates/>
  </step3>
</xsl:template>

<xsl:template match="listlevel">
  <text>
    <xsl:apply-templates/>
  </text>
</xsl:template>

<xsl:template match="note">
  <xsl:copy-of select="."/>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>rem Done!



--
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.