xsl-list
[Top] [All Lists]

[xsl] processing xml data with default namespace

2006-07-12 12:05:30
hey list,

i'm trying to process xml data that has a default namespace:

<--- snip: test.xml --->
<?xml version="1.0" encoding="utf-8"?>
<foo xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
         xmlns="http://www.patexpert.org/ont/metaont#";>
        <bar rdf:about="#id">argh</bar>
</foo>
<--- snip --->


processing this data with the stylesheet

<--- snip: test1.xsl --->
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:pat="http://www.patexpert.org/ont/metaont#";
                exclude-result-prefixes="pat"
                version="2.0">

        <xsl:output method="xml" version="1.0" indent="yes" encoding="utf-8" />

        <xsl:template match="pat:foo">
                <xsl:element name="bar"
                namespace="http://www.patexpert.org/ont/metaont#";>
                </xsl:element>
        </xsl:template>

</xsl:stylesheet>
<--- test1.xsl --->

yields the (expected) result

<--- snip:output1 --->
<?xml version="1.0" encoding="utf-8"?>
<bar xmlns="http://www.patexpert.org/ont/metaont#"/>
<--- snip --->

i was trying to replace the xsl:element tags with a more direct

<--- snip:test2.xsl --->
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                xmlns:pat="http://www.patexpert.org/ont/metaont#";
                exclude-result-prefixes="pat"
                version="2.0">

        <xsl:output method="xml" version="1.0" indent="yes" encoding="utf-8" />

        <xsl:template match="pat:foo">
                <pat:bar>
                </pat:bar>
        </xsl:template>

</xsl:stylesheet>
<--- snip --->

but i am getting

<--- snip: output2 --->
<?xml version="1.0" encoding="utf-8"?>
<pat:bar xmlns:pat="http://www.patexpert.org/ont/metaont#"/>
<--- snip --->

i was expecting to get the same result as in output1. why is pat:bar apparently not the same as the xsl:element instruction above?

thanks,

achim.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>