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

xsl transform

Subject: xsl transform
From: "Philippe LAPLANCHE" <philippe.laplanche@xxxxxxxxxxxx>
Date: Tue, 28 Jun 2005 15:58:19 +0200
xsl access attributes
Hello,

Does somebody has a neet way to convert this tree :
<?xml version="1.0" encoding="UTF-8"?>
<results>
<row>
	<param1>p1</param1>
	<param2>p2</param2>
	<param3>p3</param3>
	<param4>p4</param4>
	<param5>p5</param5>
	<param6>p6</param6>
	...
      <paramn>pn</paramn>
</row>
<row>
	...
</row>
</results>

Into this one :
<?xml version="1.0" encoding="UTF-8"?>
<root fields="param1|param2|param3 ... ">
	<e a="p1" b="p2" c="p3" d="p4" e="p5" f="p6" ... z="p26" aa="p27" ab="p28"
... az="p52" ba="p53" .... zz="p702" />
</root>



I'm thinking of using a list of attributes names but I can't find how-to

First I don't know how to define a list, I want something like that:

<xsl:variable name="attributes">
   a,b,c,d,e,...
</xsl:variable>
In order to access attributes[n] and use it as an xsl:attribute's name

I'd have templates that look like that :

<xsl:template match="/results"> (this works fine)
	<root>
		<xsl:attribute name="fields">
			<xsl:for-each select="row[1]/*">
				<xsl:value-of select="local-name()"/>
				<xsl:if test="not(position()=last())">|</xsl:if>
			</xsl:for-each>
		</xsl:attribute>
		<xsl:apply-templates/>
	</root>
</xsl:template>

<xsl:template match="row"> (this I don't know how to make it work)
	<e>
		<xsl:for-each select="*">
			<xsl:attribute name="????">
				<xsl:value-of select="."/>
			</xsl:attribute>
		</xsl:for-each>
	</e>
</xsl:template>

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.