Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSL Transformation Error

 
Himanshu Jhamb
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
Himanshu Jhamb
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic