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

RE: xsl transform

Subject: RE: xsl transform
From: "Philippe LAPLANCHE" <philippe.laplanche@xxxxxxxxxxxx>
Date: Tue, 28 Jun 2005 18:08:50 +0200
xsl convert elements to attributes
Thanks to Joris and Michael, their solution works like a charm!

To David:
The input format may look nicer but it also consumes (A LOT) more bandwidth
when you send huge data files with eventually long elements names. And I don't
mind if the order of attributes changes. The xml parser I use doesn't rely on
the order to get the values.

Philippe

-----Message d'origine-----
De : Michael Kay [mailto:mike@xxxxxxxxxxxx]
Envoyi : mardi 28 juin 2005 17:16
@ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Objet : RE:  xsl transform

You can get the attribute names you want using

<xsl:for-each select="row">
  <xsl:variable name="aname"><xsl:number format="a"/></xsl:variable>
  <xsl:attribute name="{$aname}"><xsl:value-of select="."/></xsl:attribute>
</xsl:for-each>

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Philippe LAPLANCHE [mailto:philippe.laplanche@xxxxxxxxxxxx]
> Sent: 28 June 2005 15:27
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  xsl transform
>
> Thanks for the quick answer.
>
> My problem is not simply to convert elements to attributes. I
> also want to change attributes names to have them as short as
> possible. e.g. param1 becomes a, param2 becomes b, param3
> becomes c ... to keep real attributes names, I use the
> attribute called fields in the root element.
>
> Here's an example :
>
> <root fields="param1|param2|param3 ... ">
> 	<e a="p1" b="p2" c="p3" d="p4" e="p5" f="p6" ... />
> 	<e a=....                                        />
> </root>
>
> -----Message d'origine-----
> De : James Fuller [mailto:jim.fuller@xxxxxxxxxxxxxx]
> Envoyi : mardi 28 juin 2005 16:16
> @ : xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Objet : Re:  xsl transform
>
> Philippe LAPLANCHE wrote:
>
> >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>
> >
> >
> >
> >
> >
> something like http://www.dpawson.co.uk/xsl/sect2/N1553.html#d2005e139
> will point u in the right direction.
>
> gl, Jim Fuller
>
> note : try to use a descriptive subject line helps those who have the
> same prob later on
>
> --------------------------------------------------------------
> -------------------------
> Wanadoo vous informe que cet  e-mail a ete controle par
> l'anti-virus mail.
> Aucun virus connu a ce jour par nos services n'a ete detecte.

-----------------------------------------------------------------------------
----------
Wanadoo vous informe que cet  e-mail a ete controle par l'anti-virus mail.
Aucun virus connu a ce jour par nos services n'a ete detecte.

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.