Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


How to add namespace attribute to transformed xml?

From: MarcusGattinger@-----------.---------.---
To: NULL
Date: 8/15/2006 9:09:00 AM

Hi,

I´ve got the following problem and need help for it.

Given the following source xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Table xmlns="x-schema:Account_Schema.xml">
   <Account>0815</Account>
</Table>


What I want is to transform this into the following:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.opendata.de/COMPASS/Account 
Account.xsd">
   <Account>0815</Account>
</Table>


So I tried this XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes" 
/>
   <xsl:template match="/Table">
      <xsl:element name="Table">
         <xsl:attribute name="xmlns:xsi">
            <xsl:value-of select="http://www.w3.org/2001/XMLSchema-instance" 
/>
         </xsl:attribute>
         <xsl:attribute name="xsi:schemaLocation">
            <xsl:value-of select="http://www.opendata.de/COMPASS/Account 
Account.xsd" />
         </xsl:attribute>
         <xsl:element name="Account">
            <xsl:value-of select="Account" />
         </xsl:element>
      </xsl:element>
   </xsl:template>
</xsl:stylesheet>

The transformation is done by some VB6-code, mainly by invoking the method 
"transformNode" on a instance variable of the type "MSXML2.DOMDocument40".

What I get is an error message like this: "The value of the 'name' attribute 
may not be 'xmlns:xsi'."

If I comment out the two <xsl:attribute> elements I receive the following:
<?xml version="1.0"?>0815

I haven´t any idea how to solve the problem. So I highly appreciate any 
help. Thank you in advance!

Kind regards,
Marcus


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent