xml – XSLT namespace axis seems not to work – Education Career Blog

I have the following xslt:

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

    <xsl:template match="/">
        <xsl:value-of select="document('')/xsl:stylesheet/namespace::my"/>
    </xsl:template>
</xsl:stylesheet>

ant it always returns an empty string.

What is wrong with namespace::*?

Update: sample xml is:

<?xml version="1.0" encoding="utf-8"?>
<foo/>

,

With MSXSL (3 and 4), Altova, Saxon, Oracle and XQSharp, it outputs:

my_namespace

If this is not the output for your processor, then maybe it doesn’t handle namespace axis.

,

Savva, I ran your stylesheet with xsltproc (under oXygen), and it output my_namespace as desired.

xsltproc is just a command-line frontend to libxslt. So (unless they changed something in recent versions), you and I should be getting the same results.

Why don’t you show us your PHP / SimpleXML code – maybe the problem is in how you’re accessing the result.

Leave a Comment