This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes resolve namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "resolve namespace " Watch "resolve namespace " New topic
Author

resolve namespace

S. Palanigounder
Ranch Hand

Joined: Apr 03, 2003
Posts: 145
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
You shouldn't define the namespace as an ordinary attribute.
Try something like this instead:


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
S. Palanigounder
Ranch Hand

Joined: Apr 03, 2003
Posts: 145
Thanks Lasse. It works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resolve namespace
 
Similar Threads
xml to xml transform
XSL Transformation Error
XSLT problem.
Namespace problem in xslt
XML Tranformation using XSLT