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

What's wrong with it?

 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i've the following xml file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>
<!-- Edited with XML Spy v4.2 -->
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<catalog>
here is the "cdcatalog.xsl"
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="catalog/cd/title"/>
</xsl:template>
</xsl:stylesheet>
i am expecting to get "Empire Burlesque" but got nothing at all. can anybody point out what's wrong with it?
thanks.
himal
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works for me with XML Spy 4.4!
The closing tag of catalog is not right.
Cheers,
Dan
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himal,
I'm using xalan xslt processor and getting the following output -
<?xml version="1.0" encoding="UTF-8"?>
Empire Burlesque
Also, you need to close the xml document properly with </catalog> (a little typo in ur pasted code)
Do you want to just see "Empire Burlesque" and not even the <?xml....?> stuff??
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
Any idea as to how to get rid of this <?xml...?> stuff from the output; I guess the processor is sticking it out there and even has nothing to do with PI node as this is not a PI.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm seeing this stuff -
<?xml version="1.0" encoding="UTF-8"?>
when i open it in a notepad and not the IE.
 
Himal Chuli
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for you guys' prompt reply. looks like i don't have xslt processor installed and i didn't know that i should have it. i just tried opening that xml file in IE5 browser and got nothing.
appreciate it if you guys suggest me the processor that i should install and the place that i can download it. pls also point out the steps to install it.
thanks again for your help.
himal
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Himal,
You can get Apache's Xalan-Java xslt processor here -
http://xml.apache.org/xalan-j/
Read the instructions there as to how to install it and make sure that you got everything right after setting all the CLASSPATH variables properly by running the command (from a msdos prompt)
java org.apache.xalan.xslt.Process
All this stuff is given in there.
The reason why it failed to open the xml file in IE for you is the missing / for the closing catalog tag as Dan pointed out; Also you should have the xsl file in the same directory as your xml so that IE can apply the stylesheet on ur xml document and show you the result in IE.
 
Gobiraj Vadivelrajan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IE5 uses a old XSLT Namespace.
Change the namespace to http://www.w3.org/TR/WD-xsl and it will work
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gobiraj,
I think he is mainly having problem with the closing "/" tag for his catalog element. I could see the resulting xml after the xsl transformation in IE6 with the old namespace http://www.w3.org/1999/XSL/Transform.
 
Gobiraj Vadivelrajan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this website also for the namespace problem in IE5
http://www.javertising.com/webtech/xmlnames.asp
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayadev,
Any idea as to how to get rid of this <?xml...?> stuff from the output;

should do it.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dan.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic