Subject: Re: [xsl] Axis specifier questions once again From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Wed, 11 Nov 2009 16:01:24 -0500 |
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.
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>
<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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Axis specifier questions once, a kusa | Thread | Re: [xsl] Axis specifier questions , a kusa |
[xsl] Consolidating three xml reque, Anonymous Anonymous | Date | Re: [xsl] Consolidating three xml r, G. Ken Holman |
Month |