xsl-list
[Top] [All Lists]

Re: Creating HTML by selecting XML attribute names

2005-09-15 10:57:17
Hi,

Tempore 19:38:09, die 09/15/2005 AD, hinc in 
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Julian Karsten Arthur 
<julian(_dot_)arthur(_at_)bsb(_dot_)politec(_dot_)com(_dot_)br>:

I am trying to convert some XML to HTML using the latest version of Xalan. 
However, I am having difficulty in selecting the correct elements from my XML 
source file. What I am trying to do is select the data from the rows/row/fields 
in the order it appears in the columns/column, and output it to a HTML table. 
The XML itself is generated so the attributes of the columns could change each 
time. I.e. in this example we have the attributes 'name' and 'age', but next 
time round they could be 'title', 'name', 'address'.

It seems all necessary information is included in the XML. Just try something 
like:

<xsl:variable name="columns" select="/table/table-config/columns/column"/>

<xsl:template match="table">
<xsl:copy>
        <tr>
                <xsl:for-each select="$columns">
                        <th><xsl:value-of select="@label"/></th>
                </xsl:for-each>   
        </tr>
    <xsl:apply-templates select="rows"/>
</xsl:copy>
</xsl:template>


<xsl:template match="field">
<xsl:variable name="field" select="."/>
<tr>
        <xsl:for-each select="$columns">
                <td>
                        <xsl:copy-of select="@align"/>
                        <xsl:value-of 
select="$field/@*[name()=current()/@field]"/>
                </td>
        </xsl:for-each>
</tr>
</xsl:template>


regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Fiat W3C in tenebris

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>