wood burning stoves 2.0*
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL Transformation Error" Watch "XSL Transformation Error" New topic
Author

XSL Transformation Error

Himanshu Jhamb
Ranch Hand

Joined: Aug 01, 2001
Posts: 134
Hi.
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 (http://www.xmlspy.com) -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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".
thanks!


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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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>
<![CDATA[AA]]></xsl:element>
------------------------------
Produces the following result
------------------------------
<VER srcTag="S7" xmlPath="LSR/1/ADM/1/VER/1">$
^I^I^I^I^I^IAA</VER>$
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: http://aspose.com/file-tools
 
subject: XSL Transformation Error