[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Iteration in XSL
Subject: [xsl] Iteration in XSL From: Daniel Celdran <danielceldran@xxxxxxxxxxxxxxxx> Date: Thu, 28 Dec 2000 17:28:18 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Node positions with xsl:n, Chris Bayes | Thread | RE: [xsl] Iteration in XSL, Chris Bayes |
[xsl] Node positions with xsl:numbe, Bill Shaw - EBCX | Date | [xsl] Conditional text using attrib, Beth Fischi |
Month |