[xsl] CLARIFICATION ON NAMESPACE

Subject: [xsl] CLARIFICATION ON NAMESPACE
From: Arul Kumar <arulxml@xxxxxxxxxxxx>
Date: Thu, 27 May 2004 08:06:51 +0530
Hello all,

Greetings

My xml having the root element called 'root', two child elements 'head', both the head element having the namespace declaration 'fa' and 'fb' respectively, and having the child called 'title'.

In my memory, some time ago I read about the namespace declaration as 'The namespace declaration given for the current element is also valid for all children and descendants'. According to this, can I able to treat (in XSL) the 'title' element as 'fa:title' and 'fb:title'?

When I do so, in view the xml in IE, I couldn't see the expected result? Please find my XML and XSL appended below.

My XML (test.xml):

<?xml-stylesheet type="text/xsl" href="main.xsl"?>
<root>
   <head xmlns:fa="http://www.test.com/element-a";>
       <title>I am in file 'fa'</title>
   </head>
   <head xmlns:fb="http://www.test.com/element-b";>
       <title>I am in file 'fb'</title>
   </head>
</root>

My XSL (main.xsl):

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns="http://www.test.com/xml";
xmlns:fa="http://www.test.com/element-a";
xmlns:fb="http://www.test.com/element-b";>
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<p style="color:red">FA: <xsl:value-of select="string(//*/*/fa:title)"/></p>
<p style="color:blue">FB: <xsl:value-of select="string(//*/*/fb:title)"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


Please advice, how to achieve this? Or my understanding is wrong? Please share your valuable comments. Many thanks in advance.

Kind regards
Arul

Current Thread