• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xmlns and xsl

 
Kamal BK
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
If my input xml is like below, then i 'm able to write xsl to retrieve data and display it (http://www.w3schools.com/xsl/xsl_transformation.asp)

[b]BUT[b]
if my input xml is like this then i am not getting any output.

the difference between first and last xml is xmlns="foo".
Please help me on how to write xsl for the above xml.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which parser/transformation implementation are you using? Could you post the XSL you got working for the no-namespace version?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, glad I left the browser window open when I left earlier...
Congratulations for your first post at the JavaRanch!
 
Kamal BK
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
Hey, glad I left the browser window open when I left earlier...
Congratulations for your first post at the JavaRanch!

Thanks for replying Lasse,
I took the xsl example from http://www.w3schools.com/xsl/xsl_transformation.asp I'm using xalan for java latest. For the second case i have not changed the xsl code.
 
Kamal BK
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
Hey, glad I left the browser window open when I left earlier...
Congratulations for your first post at the JavaRanch!

The xsl that I'm trying for the second case..
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns="www.xml.com" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template></xsl:stylesheet>
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
 
Kamal BK
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lasse Koskela:
Try this:

Thanks Lasse, Its working now!.. I'm happy.
May i know how did you learned this or what book you referred for this ?
Thanks again.
Kamal
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't use any book. Only the XSL spec and experimenting
However, if you want a book recommendation, I've been very happy with XML: The Complete Reference. It's a reference, not a "learn XML" book, but it has worked for me as a companion for online tutorials etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic