Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resolve namespace

 
S. Palanigounder
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm transfering one xml to another using xslt.
My transfer.xsl file is something like this:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" standalone="yes" indent="yes"/>
<xsl:template match="source_root">
<xsl:element name="target_root">
<xsl:attribute name="xmlns:xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
...
When I used Xalan-Java2.5.1 to do the transferformation, I got the following error:
file:///C:/xsl/transfer.xsl; Line #0; Column #0; Could not resolve namespace prefix: xmlns. The node will be ignored.
And there was no namespace prefix definition (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance") was shown in the <target_root> element.
Can someone help on this? Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't define the namespace as an ordinary attribute.
Try something like this instead:
 
S. Palanigounder
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Lasse. It works.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic