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

RE: Re: XSL to write XML tag values in columns

Subject: RE: Re: XSL to write XML tag values in columns
From: "Jaime Stuardo" <jstuardo@xxxxxxxxxxx>
Date: Tue, 23 Dec 2003 19:11:08 -0400
xsl write xml
Sorry.. but I forgot to tell 2 things:

1) That XML was only an example. The orifinal XML will be dynamic... so f_key may have value 1, 2 or n.

2) This is the right structure I want to achieve:

<table>
  <tr>
    <td>f_key = 1</td>
    <td>f_key = 2</td>
  </tr>
  <tr>
    <td>blabla</td>
    <td>blibli</td>
  </tr>
  <tr>
    <td>bleble</td>
    <td>bloblo</td>
  </tr>
</table>

That HTML produces this output:

f_key = 1  f_key = 2
blabla     blibli
bleble     bloblo

Thanks
Jaime

> -----Mensaje original-----
> De: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]En nombre de Dimitre
> Novatchev
> Enviado el: Martes, 23 de Diciembre de 2003 17:01
> Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Asunto:  Re: XSL to write XML tag values in columns
> 
> 
> 
> "Jaime Alejandro Stuardo Bahamonde" <jstuardo@xxxxxxxxxxx> 
> wrote in message
> news:CA4A243A1C219949AABAEBF59C313C3D3AB9E7@xxxxxxxxxxxxxxxxxx
> > Hi all..
> >
> > I have an XML like this:
> >
> > <test>
> >   <ROW>
> >     <f_key>1</f_key>
> >     <field>blabla</field>
> >   </ROW>
> >   <ROW>
> >     <f_key>1</f_key>
> >     <field>bleble</field>
> >   </ROW>
> >   <ROW>
> >     <f_key>2</f_key>
> >     <field>blibli</field>
> >   </ROW>
> >   <ROW>
> >     <f_key>2</f_key>
> >     <field>bloblo</field>
> >   </ROW>
> > </test>
> >
> > I want that to be shown this way:
> >
> > 1           2
> > blabla     blibli
> > bleble     bloblo
> >
> > Using muenchian method I could achieve:
> >
> > 1           2
> > blabla     bleble
> > blibli     bloblo
> >
> > what I was not wanting.
> >
> > Long time ago someone suggested me a way to do it and it 
> worked, by using
> mode="row" in XSL but I don't remember exactly how can I use it.
> 
> 
> This transformation:
> 
> <xsl:stylesheet version="1.0"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
>   <xsl:output method="text"/>
> 
>   <xsl:key name="kValByField" match="field"
>        use="preceding-sibling::f_key[1]"/>
> 
>   <xsl:template match="/">
>     <xsl:value-of select="concat('   1','&#09;','   2','&#xA;')"/>
> 
>     <xsl:call-template name="twoColTable">
>       <xsl:with-param name="pCol1" select="key('kValByField', '1')"/>
>       <xsl:with-param name="pCol2" select="key('kValByField', '2')"/>
>     </xsl:call-template>
>   </xsl:template>
> 
>   <xsl:template name="twoColTable">
>     <xsl:param name="pCol1" select="/.."/>
>     <xsl:param name="pCol2" select="/.."/>
> 
>     <xsl:variable name="vnumCol1" select="count($pCol1)"/>
>     <xsl:variable name="vnumCol2" select="count($pCol2)"/>
> 
>     <xsl:variable name="vLongerCol"
>      select="$pCol1[last() > $vnumCol2]
>             |
>              $pCol2[last() >= $vnumCol1]"/>
> 
> 
>     <xsl:for-each select="$vLongerCol">
>       <xsl:variable name="vPos" select="position()"/>
>       <xsl:value-of select="concat($pCol1[position() = $vPos],
>                                    '&#09;',
>                                    $pCol2[position() = $vPos],
>                                    '&#xA;'
>                                    )"/>
>     </xsl:for-each>
>   </xsl:template>
> </xsl:stylesheet>
> 
> when applied on this source.xml:
> 
> <test>
>   <ROW>
>     <f_key>1</f_key>
>     <field>blabla</field>
>   </ROW>
>   <ROW>
>     <f_key>1</f_key>
>     <field>bleble</field>
>   </ROW>
>   <ROW>
>     <f_key>2</f_key>
>     <field>blibli</field>
>   </ROW>
>   <ROW>
>     <f_key>2</f_key>
>     <field>bloblo</field>
>   </ROW>
>   <ROW>
>     <f_key>1</f_key>
>     <field>bleubleu</field>
>   </ROW>
> </test>
> 
> produces the wanted result:
> 
>    1    2
> blabla blibli
> bleble bloblo
> bleubleu
> 
> 
> 
> Dimitre Novatchev.
> FXSL developer
> 
> http://fxsl.sourceforge.net/ -- the home of FXSL
> Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
> 
> 
> 
> 
>  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

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.