This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
how to output previous and next values within for-each loop.
- From: "Uslu, Cihan Y (MED)" <Cihan dot Uslu at med dot ge dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 26 Nov 2001 16:57:07 -0600
- Subject: [xsl] how to output previous and next values within for-each loop.
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi,
I am working on a XSL script to automate the previous and next links
within HTML pageby using XSL to extract the data from XML file and
I am not sure how to output the previous and next values in for-each
loop.
I am posting XSL script, current output and desired output, with the XML
file to give you better explanation of this problem.
Thanks....
-------------XSL script----------------
<xsl:for-each select="module">
<xsl:if test="child::* = intro">
<xsl:variable name="section_num_mod_intro">
<xsl:value-of select="./intro/@sectionNum "/>
</xsl:variable>
<xsl:variable name="screen_num_mod_intro">
<xsl:value-of select="./intro/@screenNum"/>
</xsl:variable>
<xsl:text>var m0</xsl:text><xsl:value-of
select="$moduleNum"/><xsl:text>_</xsl:text><xsl:value-of
select="$section_num_mod_intro"/><xsl:text>_</xsl:text><xsl:value-of
select="$screen_num_mod_intro"/><xsl:text>= new Array('</xsl:text>
<xsl:value-of select="./title/para/text()"/>
<xsl:text>',</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:for-each select="./concept | ./conceptOrgan | ./task | ./process ">
<xsl:if test="child::* = intro">
<xsl:variable name="section_num_mod_intro">
<xsl:value-of select="./intro/@sectionNum "/>
</xsl:variable>
<xsl:variable name="screen_num_mod_intro">
<xsl:value-of select="./intro/@screenNum"/>
</xsl:variable>
<xsl:text>var m0</xsl:text><xsl:value-of
select="$moduleNum"/><xsl:text>_</xsl:text><xsl:value-of
select="$section_num_mod_intro"/>
<xsl:text>_</xsl:text><xsl:value-of
select="$screen_num_mod_intro"/><xsl:text>= new Array('</xsl:text>
<xsl:value-of select="normalize-space(./title/para/text())"/>
<xsl:text>',</xsl:text>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:variable name="section_num">
<xsl:value-of select="@sectionNum "/>
</xsl:variable>
<xsl:for-each select=" ./conceptDetail | ./grossAnatomy |
./physiology | ./imagedAnatomy | ./indications | ./approach |
./measurements | ./interactions">
<xsl:variable name="screen_num">
<xsl:value-of select="@screenNum "/>
</xsl:variable>
<xsl:text>var m0</xsl:text><xsl:value-of
select="$moduleNum"/><xsl:text>_</xsl:text><xsl:value-of
select="$section_num"/><xsl:text>_</xsl:text><xsl:value-of
select="$screen_num"/><xsl:text>= new Array('</xsl:text>
<xsl:value-of select="normalize-space(./title/para/text())"/>
<xsl:text>',</xsl:text>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
-------------------------------current output
out.txt----------------------------------------------
var m01_010_000= new Array('LightSpeed Ultra Overview',
var m01_020_000= new Array('New Features',
var m01_020_010= new Array('8 Slice Operation',
var m01_020_011= new Array('8x1.25mm and 8x2.5mm Modes',
var m01_020_012= new Array('Check Your Understanding',
var m01_020_020= new Array('New Axial Prescription Screen',
var m01_020_030= new Array('Helical Configurations',
var m01_020_031= new Array('Helical Pitch',
var m01_020_040= new Array('New Helical Prescription Screen',
var m01_020_041= new Array('Scan Example',
var m01_020_042= new Array('Scan Example',
var m01_020_043= new Array('Scan Example',
var m01_020_050= new Array('Check Your Understanding',
var m01_020_060= new Array('Benefits to the Customer',
var m01_030_000= new Array('LightSpeed Ultra Specifications',
var m01_030_010= new Array('First Release and Features to Follow',
var m01_030_020= new Array('Product Data Sheet',
var m01_040_000= new Array('Data Acquisition Changes',
var m01_040_010= new Array('System Block Diagram',
-------------desired_out.txt----------------------
var m01_010_000= new Array('LightSpeed Ultra
Overview','0','m01_020_000')
var m01_020_000 = new Array('New
Features','m01_010_000','m01_020_010','1');
var m01_020_010 = new Array('8 Slice
Operation','m01_020_000','m01_020_011','1');
var m01_020_011 = new Array('8X1.25 and 8X2.5
Modes','m01_020_010','m01_020_012','1');
var m01_020_012 = new Array('Check Your
Understanding','m01_020_011','m01_020_020','1');
var m01_020_020 = new Array('New Axial Prescription
Screen','m01_020_012','m01_020_030','1');
var m01_020_030 = new Array('Helical
Configurations','m01_020_020','m01_020_031','1');
var m01_020_031 = new Array('Helical
Pitch','m01_020_030','m01_020_040','1');
var m01_020_040 = new Array('New Helical Prescription
Screen','m01_020_031','m01_020_041','1');
var m01_020_041 = new Array('Scan
Example','m01_020_040','m01_020_042','1');
var m01_020_042 = new Array('Scan
Example','m01_020_041','m01_020_043','1');
var m01_020_043 = new Array('Scan
Example','m01_020_042','m01_020_050','1');
var m01_020_050 = new Array('Check Your
Understanding','m01_020_043','m01_020_060','1');
var m01_020_060 = new Array('Benefits to the
Customer','m01_020_050','m01_030_000','1');
var m01_030_000 = new Array('Light Speed Ultra
Specifications','m01_020_060','m01_030_010','1');
var m01_030_010 = new Array('Features to
Follow','m01_030_000','m01_030_020','1');
var m01_030_020 = new Array('Product Data
Sheet','m01_030_010','m01_040_000','1');
var m01_040_000 = new Array('Data Acquisition
Changes','m01_030_020','m01_040_010','1');
var m01_040_010 = new Array('System Block
Diagram','m01_040_000','0','1');
-------------test.xml----------------
<course courseNum="ct525" delete-modules="N">
<courseInfo>
<title>
<para>LightSpeed Ultra</para>
</title>
<courseDesc moduleNum="00" sectionNum="005" screenNum="000"/>
</courseInfo>
<module moduleNum="01" test-type="S">
<title>
<para>LightSpeed Ultra Overview</para>
</title>
<intro sectionNum="010" screenNum="000">
</intro>
<competency/>
<concept sectionNum="020">
<title>
<para>New Features</para>
</title>
<intro sectionNum="020" screenNum="000">
<para></para>
</intro>
<conceptDetail screenNum="010">
<title>
<para>8 Slice Operation</para>
</title>
</conceptDetail>
<conceptDetail screenNum="011">
<title>
<para>8x1.25mm and 8x2.5mm Modes</para>
</title>
</conceptDetail>
<interactions screenNum="012" type="matching">
<title>
<para>Check Your Understanding</para>
</title>
</interactions>
<conceptDetail screenNum="020">
<title>
<para>New Axial Prescription Screen </para>
</title>
</conceptDetail>
<conceptDetail screenNum="030">
<title>
<para>Helical Configurations</para>
</title>
</conceptDetail>
<conceptDetail screenNum="031">
<title>
<para>Helical Pitch </para>
</title>
</conceptDetail>
<conceptDetail screenNum="040">
<title>
<para>New Helical Prescription Screen</para>
</title>
</conceptDetail>
<conceptDetail screenNum="041">
<title>
<para>Scan Example</para>
</title>
</conceptDetail>
<conceptDetail screenNum="042">
<title>
<para> Scan Example</para>
</title>
</conceptDetail>
<conceptDetail screenNum="043">
<title>
<para>Scan Example</para>
</title>
</conceptDetail>
<interactions screenNum="050" type="multchoice">
<title>
<para>Check Your Understanding</para>
</title>
</interactions>
<conceptDetail screenNum="060">
<title>
<para>Benefits to the Customer</para>
</title>
</conceptDetail>
</concept>
<concept sectionNum="030">
<title>
<para>LightSpeed Ultra Specifications</para>
</title>
<intro sectionNum="030" screenNum="000">
</intro>
<conceptDetail screenNum="010">
<title>
<para>First Release and Features to
Follow</para>
</title>
</conceptDetail>
<conceptDetail screenNum="020">
<title>
<para>Product Data Sheet</para>
</title>
</conceptDetail>
</concept>
<concept sectionNum="040">
<title>
<para>Data Acquisition Changes </para>
</title><intro sectionNum="040" screenNum="000"/>
<conceptDetail screenNum="010">
<title>
<para>System Block Diagram</para>
</title>
</conceptDetail>
</concept>
</module>
</course>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list