W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2006

Re: AW: XML transformation with changed XSD

From: George Cristian Bina <george@oxygenxml.com>
Date: Mon, 20 Feb 2006 14:30:27 +0200
Message-ID: <43F9B663.6090007@oxygenxml.com>
To: Udo Ende <u.ende@mid.de>
Cc: 'Michael Kay' <mike@saxonica.com>, 'Xmlschema-Dev-Request' <xmlschema-dev@w3.org>

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
http://www.oxygenxml.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 helps
> with that.
> 
> Udo
> 
> -----Ursprüngliche Nachricht-----
> Von: Michael Kay [mailto:mike@saxonica.com] 
> 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 schemas
> and then generate an XSLT transformation by drawing lines from one to the
> other, work particularly well when the two schemas are very similar.
> 
> Michael Kay
> http://www.saxonica.com/
> 
> 
> 
> 
> 
Received on Monday, 20 February 2006 12:28:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:53 GMT