How to re-parse information to a different purpose with XSL?

Subject: How to re-parse information to a different purpose with XSL?
From: zze-minitel2001 balr002 <minitel2001.balr002@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Jun 1999 18:28:15 +0200
I'm novice in XSL and I have the following problem when converting data
described in xml to generated HTML.
 
<data>
    <listItem1>
        <item1>
            <name>toto</name>
            <id>001</id>            
        <item1>
        <item1>
            <name>titi</name>
            <id>002</id>            
        <item1>
    </listItem1>
    <listItem2>
        <item2>...</item2>
    </listItem2>
</data>    
 
In my page, I want, first to display the names listItem1, then display
listItem2, then display again info on item1 (to put buttons for example).
The only solution I've found is this one but it's not very convenient for me
and I would like to know if there is another one:
 
 <!-- Root xsl:template - start processing here -->
 <xsl:template match="/">
    <!-- Here we build the table of item1 and the item2 info -->
    <xsl:apply-templates select="/data/*"/>
    <!-- Then I want to parse all item1 again, but with another rule! -->
    <xsl:apply-templates select="//listItem1/item1/*"/>
 </xsl:template>
<!-- For the first pass -->
<xsl:template match="listItem1">
    <TABLE border="double">
    <xsl:apply-templates select="item1" />
    </TABLE>
</xsl:template>
 
<xsl:template match="item1">
    <TD><xsl:value-of select="name"/></TD>
</xsl:template>
 
<xsl:template match="listItem2">
    <b>Item2</b>
</xsl:template>
 
<!-- Rules for the second pass -->
<xsl:template match="item1/id">
    <INPUT type="submit" >
        <xsl:attribute name="name"><xsl:value-of
select="from-self"/></xsl:attribute>
        <xsl:attribute name="value"><xsl:value-of
select="../name"/></xsl:attribute>
    </INPUT>
</xsl:template>
 
<!-- Rule to avoid dislpaying the name during the second pass -->
<xsl:template match="name">
</xsl:template>

 
Thanks.

----------------------------------------------------------------------------
--------
Simon Bécot 
Ingénieur développement Softeam - http://www.softeam.fr
<http://www.softeam.fr/>  -
- CNET Rennes - 
mailto:simon.becot@xxxxxxxxxx <mailto:simon.becot@xxxxxxxxxx> 
----------------------------------------------------------------------------
--------

 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread