Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - AW: XML transformation with changed XSD [Thread Next] Re: AW: XML transformation with changed XSDTo: Udo Ende <u.ende@---.--> Date: 2/20/2006 4:30:00 PM
Hi Udo,
If you want to add something you just emit that in the place you want it
added. If you want to delete something just exclude that from your
processing (do not copy that to the output).
Here it is an example that changes element a in b, adds an attribute
newAtt to the new b element and deletes an attribute toBeRemoved if it
is present on the a element:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a">
<b newAtt="1">
<xsl:apply-templates select="@*[not(name()='toBeRemoved')]"/>
<xsl:apply-templates select="node()"/>
</b>
</xsl:template>
</xsl:stylesheet>
On a document like:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a toBeRemoved="1">
<id>i1</id>
</a>
</test>
will give:
<?xml version="1.0" encoding="UTF-8"?><test>
<b newAtt="1">
<id>i1</id>
</b>
</test>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com
Udo Ende wrote:
>
> Thanks Michael and George for your answers.
>
> I tested some things, but could not find out if I can insert and delete=
. I
> haven't found something within the Oxygen XML Editor, and I do not want=
to
> ask for another trial version of stylus studio if I am not sure, it hel=
ps
> with that.
>
> Udo
>
> -----Urspr=FCngliche Nachricht-----
> Von: Michael Kay [mailto:mike@s...]
> Gesendet: Freitag, 17. Februar 2006 11:00
> An: 'Udo Ende'; 'Xmlschema-Dev-Request'
> Betreff: RE: XML transformation with changed XSD
>
>> I have a set of XML files being (correctly) validated to a
>> XSD file. Now I
>> upgrade the XSD file and therefore I have to change the XML files.
>>
>> What is the best way to automate the transformation of the
>> XML files? Are
>> there any tools that can do that?
>
> Clearly the process can't be automated. But the visual mapping tools in
> products like Stylus Studio, where you define the input and output sche=
mas
> and then generate an XSLT transformation by drawing lines from one to t=
he
> other, work particularly well when the two schemas are very similar.
>
> Michael Kay
> http://www.saxonica.com/
>
>
>
>
>
From george@o... Mon Feb 20 17:40:01 2006
Received: from lisa.w3.org ([128.30.52.41])
by frink.w3.org with esmtp ( | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
