This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: using attribute value as an attribute name OR using element value as an attribute name


David,

Hmmm. I'm afraid I don't understand how to implement your idea. I'm a
newbie, really.

I came up with this to display all columns in the row data regardless of how
many there are...

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html"/>

<xsl:template match="/">
<table width="95%" class="reporttable" cellpadding="2" cellspacing="2">
  <xsl:for-each select="/root/row">
   <tr>
    <xsl:for-each select="@*" >
     <td>
      <xsl:value-of select="." />
     </td>
    </xsl:for-each>
   </tr>
  </xsl:for-each>
 </table>
</xsl:template>

</xsl:stylesheet>

...but this doesn't let me select particular columns as defined by the user.
That's really what is going on... the config section is the result of user
prefs. I control the format of the config block, but the row tags are
straight from SQL Server (for XML RAW).

<?xml version="1.0"?>
<root>
	<config>
		<columnList>
			<column name="column1"/>
			<column name="column2"/>
			<column name="column4"/>
		</columnList>
	</config>

	<row column1="c1r1" column2="c2r1" column3="c3r1" column4="c4r1"/>
	<row column1="c1r2" column2="c2r2" column3="c3r2" column4="c4r2"/>
	<row column1="c1r3" column2="c2r3" column3="c3r3" column4="c4r3"/>
	<row column1="c1r4" column2="c2r4" column3="c3r4" column4="c4r4"/>
	<row column1="c1r5" column2="c2r5" column3="c3r5" column4="c4r5"/>

</root>


== Ross ==


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of David
Carlisle
Sent: Wednesday, September 18, 2002 10:10 AM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] using attribute value as an attribute name OR using
element value as an attribute name



this would be easier if your columnd data were elements rather than
attributes as element order is preserved, but as is, something like

<xsl:key name="cols" match="/root/config/columnList/column" use="@name"/>
....

<xsl:for-each select="row">
<xsl:for-each selct="@*[key('cols',name())]">
<xsl:sort select="name()"/>
...

untested,

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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




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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]