Jump to content

Setting namespace for attribute using XSLT


Guest natomb

Recommended Posts

Hi all,I want to use XSL to transform one XML document into another one. While doing so I have to set different namespaces for different attributes of the same element.Here is an example of what I need:

<element namespace1:attribute1="value" namespace2:attribute2="another_value"/>

I did by using the "xsl:attribute" statement:

<xsl:attribute name="attribute1" namespace="namespace1">value<xsl:attribute/><xsl:attribute name="attribute2" namespace="namespace2">another_value<xsl:attribute/>

Unfortunately this gave me the following which cannot be validated with the XSD I must use, because the xmlns:xxx attributes are disturbing:

<element xmlns:ns1="namespace1" ns1:attribute1="value" xmlns:ns2="namespace2" ns2:attribute2="another_value"/>

I also tried to write

<xsl:attribute name="namespace1:attribute1">value</xsl:attribute><xsl:attribute name="namespace2:attribute2">anohter_value</xsl:attribute>

But then my XSLT processor fails with some error messages (SAXParserException).I appreciate any help concerning this problem. The tutorials in the Internet, and their FAQ lists, did not yield any answer. Furthermore, searching in this forum and a free form search in google did not help me either.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...