This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XSL Transformation Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL Transformation Error" Watch "XSL Transformation Error" New topic

XSL Transformation Error

Himanshu Jhamb
Ranch Hand

Joined: Aug 01, 2001
Posts: 134
I am fairly new to the XSL world.. So, any help would be much appreciated.
I am trying to perform an XML to XML conversion using an XSL. I am showing the problem part of the XSL below.

<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XML Spy v4.0.1 U ( -->
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:template match="/">
<xsl:element name="Request">
<xsl:element name="ABCForm">
<xsl:attribute name="srcTagIndex">-1</xsl:attribute>
<xsl:attribute name="xsi:type">HI</xsl:attribute>
The error I get is ...
SystemId Unknown; Line 8; Column 36; Could not resolve namespace prefix: xsi. The node will be ignored.
If I replace the "xsi:type" with a random string, such as "abcd", it doesn't complain and gives me the desired XML Output.. a new attribute with value "abcd".

Himanshu Jhamb<br />SCJP2 v1.2 (April 2002)<br />SCJP2 v1.4 (May 2002)
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
In order to refer to the XSI namespace, you need to "map" it to the prefix "xsi":

(not sure if I remembered the schema URL 100% correct)

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Himanshu Jhamb
Ranch Hand

Joined: Aug 01, 2001
Posts: 134
Thanks a lot ! That fixed it. And yes, you do remember the schema correctly !
I have another question...
My result XML contains a bunch of CONTROL-I characters wherever I specified CDATA usage in my xsl.
For example, here's a sample of my xsl file...
<xsl:element name="VER">
<xsl:attribute name="srcTag">S7</xsl:attribute>
<xsl:attribute name="xmlPath">LSR/1/ADM/1/VER/1</xsl:attribute>
Produces the following result
<VER srcTag="S7" xmlPath="LSR/1/ADM/1/VER/1">$
These Control Characters are killing my code later on... Any idea(s) why the CDATA is doing this ? Am I using it correctly?
Thanks in Advance!
I agree. Here's the link:
subject: XSL Transformation Error
It's not a secret anymore!