[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Problem to place data into a specific
RE: [xsl] Problem to place data into a specific
Subject: RE: [xsl] Problem to place data into a specific <TD>
From: Roel Mertens <rmertens@xxxxxxx>
Date: Fri, 22 Dec 2000 09:14:38 +0100
hello Dimitre,
Thanks for your reply !
I've got one big problem I thin.... my clients all use IE5 and I can;'t
expect that they all install msxml3. So, I have to fix it with msmxl2, and
therefor I can't use something like <xsl:variable> and some other thinks.
Do you think there is a solution, something with javascript in it, or ?
Roel
> -----Oorspronkelijk bericht-----
> Van: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx]
> Verzonden: donderdag 21 december 2000 17:27
> Aan: rmertens@xxxxxxx
> CC: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Onderwerp: Re: [xsl] Problem to place data into a specific <TD>
>
>
> Hi Roel,
>
> Sometimes this summer I had a similar problem.
>
> Given the following xml document(pivot.xml):
> ------------------------------------------
> <root>
> <data>
> <item id='1' name='age' value='25' />
> <item id='2' name='age' value='27' />
> <item id='1' name='cool' value='yes' />
> <item id='2' name='cool' value='no' />
> </data>
> </root>
>
> The following output had to be produced:
> ---------------------------------------
> id,age,cool
> 1,25,yes
> 2,27,no
>
> Below is the stylesheet that specifies this transformation. This is
> very similar to your problem and I hope it can be of some help to you.
>
> Dimitre.
>
> The stylesheet (pivot.xsl):
> ---------------------------
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
> >
>
> <xsl:output method="text"/>
>
> <xsl:variable name="Root" select="/"/>
>
> <!-- Obtain all different "name"s -->
> <xsl:variable name="sortedNames">
> <xsl:for-each select="/root/data/item">
> <xsl:sort select="@name"/>
> <xsl:element name="name">
> <xsl:value-of select="@name"/>
> </xsl:element>
> </xsl:for-each>
> </xsl:variable>
>
> <xsl:variable name="uniqueNames">
> <xsl:for-each
> select="msxsl:node-set($sortedNames)/name[position()=1
> or . != preceding-sibling::name[1]]">
> <xsl:element name="name">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:for-each>
> </xsl:variable>
>
> <!-- Obtain all different "id"s -->
> <xsl:variable name="sortedIds">
> <xsl:for-each select="/root/data/item">
> <xsl:sort select="@id"/>
> <xsl:element name="id">
> <xsl:value-of select="@id"/>
> </xsl:element>
> </xsl:for-each>
> </xsl:variable>
>
> <xsl:variable name="uniqueIds">
> <xsl:for-each
> select="msxsl:node-set($sortedIds)/id[position()=1
> or . != preceding-sibling::id[1]]">
> <xsl:element name="id">
> <xsl:value-of select="."/>
> </xsl:element>
> </xsl:for-each>
> </xsl:variable>
>
>
>
>
> <xsl:template match="/">
> <!-- Output the "title" line -->
> <xsl:text>id,</xsl:text>
> <xsl:for-each select="msxsl:node-set($uniqueNames)/*">
> <xsl:value-of select="."/>
> <xsl:if test="position() != last()">
> <xsl:text>,</xsl:text>
> </xsl:if>
> </xsl:for-each>
>
> <!-- Output every "data" line -->
> <xsl:for-each select="msxsl:node-set($uniqueIds)/id">
> <xsl:variable name="thisId" select="."/>
>
> <!-- Output "NL" + "id" -->
> <xsl:text>
</xsl:text>
> <xsl:value-of select="."/>
> <xsl:text>,</xsl:text>
>
> <!-- Output the corresponding "value" for every "id" -->
> <xsl:for-each
> select="msxsl:node-set($uniqueNames)/name">
> <xsl:variable name="thisName" select="."/>
> <xsl:value-of select="$Root/root/data/item
> [@id=$thisId][@name=$thisName][1]/@value"/>
> <xsl:if test="position() != last()">
> <xsl:text>,</xsl:text>
> </xsl:if>
> </xsl:for-each>
> </xsl:for-each>
>
> </xsl:template>
> </xsl:stylesheet>
>
>
> Roel Mertens wrote:
>
> I have the following problem.
> Here my XML and my wanted output:
>
>
> XML:
>
> <Root>
> <Article></Article>
> <ID>1</ID>
> <code type="A">1</code>
> <code type="B">2</code>
> <code type="C">3</code>
> <Article></Article>
> <ID>2</ID>
> <code type="A">1</code>
> <code type="C">3</code>
> </Root>
>
> I want this as output (with xsl)
>
> A B C
> 1 1 2 3
> 2 1 3
>
> with a for-each the problem is the last code is placed under B like:
>
> A B C
> 1 1 2 3
> 2 1 3
>
> What can be a solution ??
> The code type is vaiable, I don't know whatr it is when I get the XML.
> So it can also be E F G or something
>
>
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Shopping - Thousands of Stores. Millions of Products.
> http://shopping.yahoo.com/
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread
- [xsl] Problem to place data into a specific <TD>
- Roel Mertens - Thu, 21 Dec 2000 08:53:35 +0100
- Jeni Tennison - Thu, 21 Dec 2000 11:43:38 +0000
- <Possible follow-ups>
- Dimitre Novatchev - Thu, 21 Dec 2000 08:27:09 -0800 (PST)
- Roel Mertens - Fri, 22 Dec 2000 09:14:38 +0100 <=
- Roel Mertens - Fri, 22 Dec 2000 09:23:40 +0100
<- Previous Index Next ->
Re: [xsl] Problem to place data int, Dimitre Novatchev
Thread
[xsl] Problem to place data into a , Roel Mertens
Re: [xsl] Remove <?xml version> lin, Derek Ngok
Date
[xsl] Problem to place data into a , Roel Mertens
Month
Keywords
Products
Features
Resources
Support
Oxygen XML on Facebook
Follow
Oxygen XML on Twitter
Oxygen XML Web Feed
Oxygen XML
Blog
Oxygen XML Youtube Channel
© 2002-2022 SyncRO Soft SRL. All rights reserved. This website was
created & generated with <oXygen/>®XML Editor
Subject: RE: [xsl] Problem to place data into a specific <TD> From: Roel Mertens <rmertens@xxxxxxx> Date: Fri, 22 Dec 2000 09:14:38 +0100 |
hello Dimitre, Thanks for your reply ! I've got one big problem I thin.... my clients all use IE5 and I can;'t expect that they all install msxml3. So, I have to fix it with msmxl2, and therefor I can't use something like <xsl:variable> and some other thinks. Do you think there is a solution, something with javascript in it, or ? Roel > -----Oorspronkelijk bericht----- > Van: Dimitre Novatchev [mailto:dnovatchev@xxxxxxxxx] > Verzonden: donderdag 21 december 2000 17:27 > Aan: rmertens@xxxxxxx > CC: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Onderwerp: Re: [xsl] Problem to place data into a specific <TD> > > > Hi Roel, > > Sometimes this summer I had a similar problem. > > Given the following xml document(pivot.xml): > ------------------------------------------ > <root> > <data> > <item id='1' name='age' value='25' /> > <item id='2' name='age' value='27' /> > <item id='1' name='cool' value='yes' /> > <item id='2' name='cool' value='no' /> > </data> > </root> > > The following output had to be produced: > --------------------------------------- > id,age,cool > 1,25,yes > 2,27,no > > Below is the stylesheet that specifies this transformation. This is > very similar to your problem and I hope it can be of some help to you. > > Dimitre. > > The stylesheet (pivot.xsl): > --------------------------- > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:msxsl="urn:schemas-microsoft-com:xslt" > > > > <xsl:output method="text"/> > > <xsl:variable name="Root" select="/"/> > > <!-- Obtain all different "name"s --> > <xsl:variable name="sortedNames"> > <xsl:for-each select="/root/data/item"> > <xsl:sort select="@name"/> > <xsl:element name="name"> > <xsl:value-of select="@name"/> > </xsl:element> > </xsl:for-each> > </xsl:variable> > > <xsl:variable name="uniqueNames"> > <xsl:for-each > select="msxsl:node-set($sortedNames)/name[position()=1 > or . != preceding-sibling::name[1]]"> > <xsl:element name="name"> > <xsl:value-of select="."/> > </xsl:element> > </xsl:for-each> > </xsl:variable> > > <!-- Obtain all different "id"s --> > <xsl:variable name="sortedIds"> > <xsl:for-each select="/root/data/item"> > <xsl:sort select="@id"/> > <xsl:element name="id"> > <xsl:value-of select="@id"/> > </xsl:element> > </xsl:for-each> > </xsl:variable> > > <xsl:variable name="uniqueIds"> > <xsl:for-each > select="msxsl:node-set($sortedIds)/id[position()=1 > or . != preceding-sibling::id[1]]"> > <xsl:element name="id"> > <xsl:value-of select="."/> > </xsl:element> > </xsl:for-each> > </xsl:variable> > > > > > <xsl:template match="/"> > <!-- Output the "title" line --> > <xsl:text>id,</xsl:text> > <xsl:for-each select="msxsl:node-set($uniqueNames)/*"> > <xsl:value-of select="."/> > <xsl:if test="position() != last()"> > <xsl:text>,</xsl:text> > </xsl:if> > </xsl:for-each> > > <!-- Output every "data" line --> > <xsl:for-each select="msxsl:node-set($uniqueIds)/id"> > <xsl:variable name="thisId" select="."/> > > <!-- Output "NL" + "id" --> > <xsl:text>
</xsl:text> > <xsl:value-of select="."/> > <xsl:text>,</xsl:text> > > <!-- Output the corresponding "value" for every "id" --> > <xsl:for-each > select="msxsl:node-set($uniqueNames)/name"> > <xsl:variable name="thisName" select="."/> > <xsl:value-of select="$Root/root/data/item > [@id=$thisId][@name=$thisName][1]/@value"/> > <xsl:if test="position() != last()"> > <xsl:text>,</xsl:text> > </xsl:if> > </xsl:for-each> > </xsl:for-each> > > </xsl:template> > </xsl:stylesheet> > > > Roel Mertens wrote: > > I have the following problem. > Here my XML and my wanted output: > > > XML: > > <Root> > <Article></Article> > <ID>1</ID> > <code type="A">1</code> > <code type="B">2</code> > <code type="C">3</code> > <Article></Article> > <ID>2</ID> > <code type="A">1</code> > <code type="C">3</code> > </Root> > > I want this as output (with xsl) > > A B C > 1 1 2 3 > 2 1 3 > > with a for-each the problem is the last code is placed under B like: > > A B C > 1 1 2 3 > 2 1 3 > > What can be a solution ?? > The code type is vaiable, I don't know whatr it is when I get the XML. > So it can also be E F G or something > > > > > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Shopping - Thousands of Stores. Millions of Products. > http://shopping.yahoo.com/ > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem to place data int, Dimitre Novatchev | Thread | [xsl] Problem to place data into a , Roel Mertens |
Re: [xsl] Remove <?xml version> lin, Derek Ngok | Date | [xsl] Problem to place data into a , Roel Mertens |
Month |
Keywords
Products
Features
Resources
Support
Oxygen XML on Facebook
Follow
Oxygen XML on Twitter
Oxygen XML Web Feed
Oxygen XML
Blog
Oxygen XML Youtube Channel
© 2002-2022 SyncRO Soft SRL. All rights reserved.
This website was created & generated with <oXygen/>®XML Editor