File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "resolve namespace " Watch "resolve namespace " New topic

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="" 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"></xsl:attribute>
<xsl:apply-templates />
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="") was shown in the <target_root> element.
Can someone help on this? Thanks.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
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:
subject: resolve namespace
It's not a secret anymore!