Subject: RE: [xsl] xsl:copy - change attributes and tag name From: "Matias Woloski" <woloski@xxxxxxxx> Date: Sat, 6 Apr 2002 18:18:06 -0300 |
Carsten, thanks for your prompt response. I have applied this new xsl but now there is no output for the child nodes I mean this is the output right now using <tree> <tree text="Omint Analisis"></tree> <tree text="Swiss Medical Analisis"></tree> </tree> I lost children. Refer to my first post to see the output required, this is the new xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <tree> <xsl:apply-templates select="TreeData/*[not(@IdRef)]"/> </tree> </xsl:template> <xsl:template match="Indice[not(@IdRef)]"> <tree> <xsl:attribute name="text"><xsl:value-of select="@Nombre"/></xsl:attribute> <xsl:for-each select="*[@IdRef = current()/@IdIndice]"> <xsl:apply-templates/> </xsl:for-each> </tree> </xsl:template> <xsl:template match="@*"> <xsl:copy/> </xsl:template> </xsl:stylesheet> thanks again for your help Carsten. Matias > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Carsten Klein > Sent: sábado, 06 de abril de 2002 17:49 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] xsl:copy - change attributes and tag name > > > Hi Matias, > > we dig directly into your questions, no time tolouse =) > > Okay here we go: > > 1) > > > : Now I want 3 things: > : 1. instead of generate <Indice> tags I want to get <tree> tags. > : So I would get > > Instead of <copy/> you will have to create a suitable template to > insert a <tree/> element into the output tree, therefore it will be > the easiest > to add a new template and thus splitting the template which matches > all "*|@*": > > <xsl:template match="Indice[not(@IdRef)]"> > <tree> > <!-- add whatever additional attributes you want to include > on tree element here --> > > <xsl:for-each select="*[@IdRef = current()/@IdIndice]"> > <xsl:apply-templates/> > <xsl:for-each> > </tree> > </xsl:template> > > <xsl:template match="@*"> > <xsl:copy/> > </xsl:template> > > 2) > if you like to change nombre attribute to text attribute > you should so in the first template, adding a <xsl:attribute > name="text"><xsl:value-of select="@Nombre"/></<xsl:attribute> > before <xsl:apply-templates/> > > 3. you are free to add any attribute you like, as long as you > keep in mind, that if you create a node in the result tree, not to > output any other element, be it CDATA or any other, before > inserting the attribute node on the element just creates. > Therefore you may not use <xsl:attribute/> after the > <xsl:apply-templates/> in the example above. > > Hope this helps > > best regards > Carsten > > > _________________________________________________________ > Do You Yahoo!? > Get your free @yahoo.com address at http://mail.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] xsl:copy - change attribu, Carsten Klein | Thread | Re: [xsl] xsl:copy - change attribu, Joerg Heinicke |
Re: [xsl] xsl:copy - change attribu, Carsten Klein | Date | Re: [xsl] xsl:copy - change attribu, Joerg Heinicke |
Month |