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(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07 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>
--~--