xsl-list
[Top] [All Lists]

Re: Interation and Variables

2005-02-09 04:47:56
Here's an XSLT2 solution:

<xsl:stylesheet version="2.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:xs="http://www.w3.org/2001/XMLSchema";

 
 <xsl:output method="text"/>
  
 <xsl:variable name="vDoc" select="/"/>
  
 <xsl:template match="/*/*[starts-with(name(),'Index')][last()]">
   
   <xsl:for-each select=
        "1 to xs:integer(substring-after(name(), 'Index'))">
     <xsl:variable name="vName" 
      select="concat('Index', xs:string(current()))"/>
     <xsl:value-of select="concat($vDoc/*/*[name()=$vName]/@Value,';')"/>
   </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>


Cheers,

Dimitre Novatchev


On Wed, 9 Feb 2005 11:16:54 -0000, Paulo Mendes Pinto
<paulo(_dot_)pinto(_at_)dsts(_dot_)pt> wrote:
Hello again

Like I've said before, I'm new in XSL and because of that my mind is not 
thinking like it.

I'm transforming XML to Text plain file (CSV) and I have this XML:
<IndexGroup>
            <Index1 ID="1" Value="Index1"/>
            <Index2 ID="2" Value="Index2"/>
</IndexGroup>

I have a XSL that transform to this
Index1;Index2;

Now I want this
<IndexGroup>
            <Index3 ID="3" Value="Index3"/>
</IndexGroup>

To be transformed in this:
;;Index3;

How can I do it ?

I'm trying to do this without changing the XML, because is property of the 
client and it's is difficult to change it. Can any one help me ??

Paulo Aboim Pinto 
Engenheiro de Produto
======================
DSTS - Desenvolvimento e Integração de Serviços e Tecnologia, S.A.
Tel.(+351)21 092 56 28
Fax.(+351)21 092 56 29

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>