This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xsl:copy - change attributes and tag name
- From: "Carsten Klein" <carstenklein at yahoo dot de>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Sat, 6 Apr 2002 22:49:22 +0200
- Subject: Re: [xsl] xsl:copy - change attributes and tag name
- References: <BBEJKGIELKMFIMGJKDMNGENFDMAA.woloski@sion.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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