This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes xmlns and xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xmlns and xsl" Watch "xmlns and xsl" New topic
Author

xmlns and xsl

Kamal BK
Greenhorn

Joined: Sep 20, 2003
Posts: 4
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
Which parser/transformation implementation are you using? Could you post the XSL you got working for the no-namespace version?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hey, glad I left the browser window open when I left earlier...
Congratulations for your first post at the JavaRanch!
Kamal BK
Greenhorn

Joined: Sep 20, 2003
Posts: 4
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

Joined: Sep 20, 2003
Posts: 4
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
Try this:
Kamal BK
Greenhorn

Joined: Sep 20, 2003
Posts: 4
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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.
 
Don't get me started about those stupid light bulbs.
 
subject: xmlns and xsl
 
Similar Threads
What's wrong with it?
Problem executing xml and xsl with IE5
accessing Attribute values of element.
Retriving Data from XML data into JSP using JSTL.
xsl for adding a tag