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

how to output previous and next values within for-each

Subject: how to output previous and next values within for-each loop.
From: "Uslu, Cihan Y (MED)" <Cihan.Uslu@xxxxxxxxxx>
Date: Mon, 26 Nov 2001 16:57:07 -0600
xsl for each previous value
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>&#10;</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>&#10;</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>&#10;</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


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.