Re: [xsl] Selecting and sorting attributes from dynamic head

Subject: Re: [xsl] Selecting and sorting attributes from dynamic head
From: Steven.C.Kienle@xxxxxxxxxx
Date: Tue, 7 Aug 2001 07:58:37 -0400
  The stylesheet you're looking for is:
  
  <xsl:stylesheet version="1.0"
          xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
     <xsl:template match="/">
          <xsl:apply-templates select="XmlData/Results/Row"/>
     </xsl:template>
  
     <xsl:template match="Row">
          <xsl:variable name="current-row" select="." />
          <tr>
          <xsl:for-each select="/XmlData/Headers/Column">
               <td>
               <xsl:value-of
                    select="$current-row/@*[name() = current()/@label]"
               />
               </td>
          </xsl:for-each>
          </tr>
     </xsl:template>
  </xsl:stylesheet>
  
  The keys are to save the current Row node in a variable, then process 
  each Column node (in document order).  Then in the XPath, select all 
  of the attributes and query to only that one whose name matches the 
  current Column's label attribute.  To do that, you need to use the 
  current() XPath function in the query.
  
     Steve


______________________________ Reply Separator _________________________________
Subject: [xsl] Selecting and sorting attributes from dynamic headers.
Author:  xsl-list@xxxxxxxxxxxxxxxxxxxxxx at Internet-America
Date:    07-08-2001 1:15 PM


My XML file is:
  
<XmlData>
        <Headers>
                <Column label="att1" />
                <Column label="att4" />
                <Column label="att2" />
                <Column label="att7" />
        </Headers>
        <Results>
                <Row att1="AAA" att2="BBB" att3="CRC" ... att10="NNN" /> 
                <Row att1="AAA" att2="BAB" att3="CCT" ... att10="NNN" /> 
                <Row att1="AAA" att2="BCB" att3="CEC" ... att10="NNN" /> 
                <Row att1="AAA" att2="DBB" att3="CCR" ... att10="NNN" /> 
                <Row att1="AAA" att2="BBE" att3="CCC" ... att10="NNN" />
        </Results>
</XmlData>
  
The Headers node is a param of my XSL file. I'd like to generate a HTML 
table with the attributes specified in the Headers node in the same order of 
the Column nodes. I thought it was simple, but I can't to it !!
  
Thanks for any help.
  
Xavier Martzel
xavier.martzel@xxxxxxxxxxx
  
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
  

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


Current Thread