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

xsl:copy - change attributes and tag name

Subject: xsl:copy - change attributes and tag name
From: "Matias Woloski" <woloski@xxxxxxxx>
Date: Sat, 6 Apr 2002 16:43:18 -0300
xsl change attribute xml
Hi folks!
I have this parent-child xml.
	<Indice IdIndice="1" Nombre="Omint Analisis" />
	<Indice IdIndice="3" IdRef="1" Nombre="OMINT: Precios"/>
	<Indice IdIndice="4" IdRef="1" Nombre="210 / Omint"/>
	<Indice IdIndice="5" Nombre="Swiss Medical Analisis"/>
	<Indice IdIndice="6" IdRef="5" Nombre="Swiss Precios"/>
	<Indice IdIndice="7" IdRef="1" Nombre="310 / Omint"/>
	<Indice IdIndice="8" IdRef="7" Nombre="Cobertura" IdDoc="1"/>

What I want to do is putting it into a hierarchical format, which I do with
this xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:template match="/">
 <xsl:apply-templates select="TreeData/*[not(@IdRef)]"/>

<xsl:template match="*|@*">
<xsl:apply-templates select="//*[@IdRef = current()/@IdIndice]|@*"/>

So I get
	<Indice IdIndice="1" Nombre="Omint Analisis">
		<Indice IdIndice="3" IdRef="1" Nombre="OMINT: Precios Directos" />
		<Indice IdIndice="4" IdRef="1" Nombre="210 / Omint" />
		<Indice IdIndice="7" IdRef="1" Nombre="310 / Omint">
			<Indice IdIndice="8" IdRef="7" Nombre="Cobertura" IdDoc="1" />
	<Indice IdIndice="5" Nombre="Swiss Medical Analisis">
		<Indice IdIndice="6" IdRef="5" Nombre="Swiss Precios" />

Now I want 3 things:
1. instead of generate <Indice> tags I want to get <tree> tags.
So I would get
	<tree ... />
	<tree ..>
		<tree ..>

2. I want to change the "Nombre" attribute to "text" attribute
So I would have
	<tree text="210/Omint" ...>
3. How do I add another attribute to each entry?
	<tree text="..." addedAttr="something">

thanks in advance!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


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.
First Name
Last Name
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.