Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT & invalid namespace

Status
Not open for further replies.

sedj

Programmer
Aug 6, 2002
5,610
Hi,

I'm using XSLT to transform an xml message into another xml format - but I need to declare an invalid 'xmlns' attribute in the root node, eg :

<DocRootNode xmlns="I_know_this_is_invalid">
<hello>there</hello>
</DocRootNode>

However, every time I attempt to generate this in XSLT, the stupid parser removes my xmlns declaration because its invalid.

I've tried putting the "xml" in <xsl:text> sections, having the output method as text etc etc, but to no avail.

Is there any way of telling the parser to stop validating and messing with my output ?

Using Saxon 8 (XSLT 2) Java parser.

Cheers

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
You cannot have a 'default' namespace (xmlns=) for xslt to parse the file.

What you need to use is

<DocRootNode xmlns:xsl="I_know_this_is_invalid">

also, if you use this namespace in any other tag other that the initial xml declaration, the parser will ignore the tag.

Hope this helps

Simon


 
Hi Simon,

Unfortunately they want :

xmlns="bla"

not :

xmlns:bla="bla"

I'll have to give up and substring it. Nice !

Thanks for the help.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Can't you declare it in the xsl:stylesheet node?
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns="I_know_this_is_invalid">

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top