Re: [xsl] namespace declaration problem creating new xml file

Subject: Re: [xsl] namespace declaration problem creating new xml file
From: Pablo Sebastian Rodriguez <psrodriguez@xxxxxxxxxxxxxxxx>
Date: Fri, 29 Aug 2008 12:19:59 -0300
the wrong namespace is some bad copy/paste operation i think, no vendor to blame for this ( i use vim )...
exclude-result-prefixes... that's perfect, thanks.


Michael Kay escribis:
Just get rid of the fn declaration from your stylesheet. (a) you're not
using it, (b) you never need to use it in XSLT, and (c) it's the wrong
namespace URI anyway. I suspect you are using some XSLT editor that adds it
automatically - write to your vendor and ask them to change this irritating
habit.

Alternatively, if you were using this namespace in your stylesheet, you
could prevent it being added to the result document using
exclude-result-prefixes="fn".

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: Pablo Sebastian Rodriguez [mailto:psrodriguez@xxxxxxxxxxxxxxxx] Sent: 28 August 2008 22:13
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] namespace declaration problem creating new xml file


Hi,
I have this input and i want to split it into multiple files, one per each "table" element


<?xml version="1.0" encoding="ISO-8859-1"?> <schema version="0.3">
    <table name="gacl_aco_map">
        <field name="acl_id" type="I" size="11">
            <KEY/>
            <DEFAULT value="0"/>
        </field>
        <field name="section_value" type="C" size="230">
            <KEY/>
            <DEFAULT value="0"/>
        </field>
        <field name="value" type="C" size="230">
            <KEY/>
        </field>
    </table>
    <table name="gacl_groups_aro_map">
        <field name="group_id" type="I" size="11">
            <NOTNULL/>
            <DEFAULT value="0"/>
        </field>
        <field name="aro_id" type="I" size="11">
            <NOTNULL/>
            <DEFAULT value="0"/>
        </field>
        <index name="gacl_aro_id">
            <col>aro_id</col>
        </index>
        <index name="group_id">
            <col>group_id</col>
        </index>
    </table>
</schema>

This is what i'm doing:

<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fn="http://www.w3.org/2005/04/xpath-functions";>


<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="table">
<xsl:variable name="file" select="concat( '/var/www/tables/', @name, '.xml' )"/>
<xsl:result-document method="xml" encoding="ISO-8859-1" href="{$file}">
<schema version="0.3">
<xsl:copy-of select="."/>
</schema>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>


The problem is that the namespace declaration ( "xmlns:fn..." ) gets added inside the root element of every file created, like this:

<?xml version="1.0" encoding="ISO-8859-1"?> <schema xmlns:fn="http://www.w3.org/2005/04/xpath-functions";
version="0.3">
<table name="gacl_aco_map">
<field name="acl_id" type="I" size="11">
<KEY/>
<DEFAULT value="0"/>
</field>
<field name="section_value" type="C" size="230">
<KEY/>
<DEFAULT value="0"/>
</field>
<field name="value" type="C" size="230">
<KEY/>
</field>
</table>
</schema>


What am i doing wrong ? Anyway to avoid this ?

Pablo

Current Thread