Page 1 of 1

default namespace in xsl

Posted: Wed May 31, 2006 4:19 pm
by miky
I receive an xml message with the following format:

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<staticMessage xmlns="Static/nme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="Static/nme ./StaticMessage.xsd">
...
</staticMessage>
I fail to apply transformation when using a stylesheet like:

Code: Select all

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="staticMessage/body/data"/>
</xsl:template>
</xsl:stylesheet>
I have tried adding the default namespace to the xsl (xmlns="Static/nme" ) without sucess.
However if I use a prefix xmlns:j="Static/nme" , I can reference my nodes with j:\

Is this a normal behavior and is there a way of using the default namespace in the xsl sheet to reference nodes and values?

Tx,
Mik.

Posted: Wed May 31, 2006 10:46 pm
by george
Hi Mik,

Yes, this is the expected behavior, name tests without prefix in Path 1.0 are in no namespace, if you want a name test in some namespace you need to use a prefix.
XPath 2.0 allows specifying a default namespace for name tests and you can do that in a stylesheet with the xpath-default-namespace attribute.

Best Regards,
George