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

Iteration in XSL

Subject: Iteration in XSL
From: Daniel Celdran <danielceldran@xxxxxxxxxxxxxxxx>
Date: Thu, 28 Dec 2000 17:28:18 +0100
iteration in xsl
Hello,

I have the next DTD:

File: section.dtd
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT sectiontitle (#PCDATA)>
<!ELEMENT subsectiontitle (#PCDATA)>
<!ELEMENT sectiontext (#PCDATA)>
<!ELEMENT section (sectiontitle+, subsectiontitle*, sectiontext+)>

As you can see, the "section" element can contain more than one
"sectiontext" (which is a normal situation).
I try to do a XSL file to transform the XML files created from this DTD and
I have problems if the XML contains more than one "sectiontext", for example
the next XML file:

File: example1.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="section.xsl"?>
<!DOCTYPE section SYSTEM "C:\work\section.dtd">		
<section>
	<sectiontitle>First section</sectiontitle>
	<subsectiontitle>section's subtitle</subsectiontitle>
	<sectiontext>First text for the first section</sectiontext>
	<sectiontext>Second text for the first section</sectiontext>
</section>

It haves two "sectiontext", for accessing to this information from the XSL
file, I made the next XSL file

File: section.xsl
<?xml version='1.0' encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
  <html>
	<body>
		<xsl:for-each select="section">
				<b><xsl:value-of
select="sectiontitle"/></b><br></br>
				<i><xsl:value-of
select="subsectiontitle"/></i><br></br>			
				<xsl:value-of
select="sectiontext[0]"/><br></br>
				<xsl:value-of
select="sectiontext[1]"/><br></br>				
				<br></br>	
		</xsl:for-each>
	</body>
  </html>
</xsl:template>
</xsl:stylesheet>

As you can see, I access to the differents "sectiontext" elements as if they
were an array, but I don't know how can I get the number of elements of this
array for make it as an iteration process.
I want to know if there is another way for accessing to all the
"sectiontext" elements without using the array position.
I have try to do it using the '<xsl:for-each select="sectiontext">' or
'<xsl:for-each select="section/sectiontext">' but it doesn't run.

How can I solve this??

Thanks in advance and excuse me for my English mistakes.

Daniel Celdran
danielceldran@xxxxxxxxxxxxxxxx



 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.