Click to See Complete Forum and Search --> : XSL and XML


s2009
04-26-2009, 01:26 PM
Hi all,

I am beginner learning XML.

I have created the following XSL file :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org" version = "1.0">
<xsl:template match = "/">
<xsl:for-each select = "MARKS/CORE">
<xsl:text>MARK IN SUBJECT 1</xsl:text>
<xsl:value-of select = "M1"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

and the XML file is as follows:
<?xml version ="1.0"?>
<?xml:stylesheet type="text/xsl"? href = "Trial.xsl"?>
<MARKS>
<CORE>
<M1>100</M1>
<M2>90</M2>
</CORE>
<ALLIED>
<M3>100</M3>
<M4>100</M4>
</ALLIED>
</MARKS>

When I run the above program in the browser it is just displaying the Text : "Mark in Subject 1" but the value of it is not displayed.

Can any one let me know the changes i should make in the XSL or the XML file?

Please I am awaiting all ur replies...

Thanks in advance!!

JohnBampton
04-27-2009, 07:59 AM
replace you stylesheet tag with this one

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version = "1.0">

and then it will work

Cheers, John Bampton.

s2009
04-27-2009, 10:06 AM
Thanks.

I have got the desired output.

But I have a doubt whether should I include the same namespace for each XSL file?

jkmyoung
04-27-2009, 11:23 AM
Yes, do it.