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

Re: Creating HTML by selecting XML attribute names

Subject: Re: Creating HTML by selecting XML attribute names
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Thu, 15 Sep 2005 19:57:17 +0200
table from xml and xslt
Hi,

Tempore 19:38:09, die 09/15/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Julian Karsten Arthur <julian.arthur@xxxxxxxxxxxxxxxxxx>:

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

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.