wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes problem in xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "problem in xsl" Watch "problem in xsl" New topic
Author

problem in xsl

srivatsan srinivasan
Greenhorn

Joined: Jun 08, 2001
Posts: 26
hi all,
i am new to the world of xsl.i tried my first example and couldn't get the ouput.if i apply the stylesheet it is showing the xml itself and not the output after the stylesheet is applied i am sending the program also which i downloaded from a website anyone please help me to get out of this
<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="srivat.xsl"?>
<PERIODIC_TABLE>
<ATOM STATE="GAS">
<NAME>Hydrogen</NAME>
<SYMBOL>H</SYMBOL>
<ATOMIC_NUMBER>1</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>1.00794</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">20.28</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">13.81</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter"><!-- At 300K -->
0.0899
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Helium</NAME>
<SYMBOL>He</SYMBOL>
<ATOMIC_NUMBER>2</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>4.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">4.216</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">0.95</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter"><!-- At 300K -->
0.1785
</DENSITY>
</ATOM>

</PERIODIC_TABLE>

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>

<xsl:template match="PERIODIC_TABLE">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="ATOM">
<P>
<xsl:value-of select="."/>
</P>
</xsl:template>

</xsl:stylesheet>
thanks in advance
srivatsan
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
The second line in your XML file should be
<?xml-stylesheet type="text/xsl" href="srivat.xsl"?>
not
<?xml-stylesheet type="text/xml" href="srivat.xsl"?>
Also, in your XSLT you use old namespace:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
here �WD-xsl� means �Working draft� and was in use some time ago, until XSL specification received final �Recomendation� status. Since then
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
is used.
Next typical reason of confusion: if you use Interner Explorer to process your XSLT, check which version of MSXML you use. Versions since 3.0 are claimed to be fully w3c compliant. The previous version, 2.6, was not fully compliant and exibited had some quirky behavior. You can check which version you use with MSXML Parser Sniffer
And here is very good FAQ about MSXML parser.

[This message has been edited by Mapraputa Is (edited June 15, 2001).]


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
srivatsan srinivasan
Greenhorn

Joined: Jun 08, 2001
Posts: 26
hi map,
Thanks it is working fine.i just changed the text/xml to text/xsl.thank u for ur timely help and also sending me the faq which is of great help.
srivatsan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem in xsl
 
Similar Threads
XSLT problem.
Why aren't DENSITY & DISTANCE text displayed?
accessing Attribute values of element.
question on apply-templates
XML Tranformation using XSLT