XSLT: default namespace problem

Hi again,

	There is/was a problem with the use of a default namespace in 
the generated XML/RDF. This has been spoted by Michael:
At 10:49 -0600 06/01/2003, Smith, Michael K wrote:
>The default namespace looks wrong.  <CheninBlanc ..> becomes
><http://www.w3.org/2003/OWL-XMLSchemaCheninBlanc ..>

This was true. What we needed is:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:xsd="http://www.w3.org/2000/10/XMLSchema#"
          xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
          xmlns:owl="http://www.w3.org/2002/7/owl#"
          xmlns="TheCorrectURI#">
  ...
</rdf:RDF>

or (less good):

<CheninBlanc xmlns="TheCorrectURI#">
</CheninBlanc>

Solution 0:
-----------

I have thus tried to introduce a correct default namespace on the 
top-level rdf tag. This has revealed impossible due to the special 
treatment that is reserved to namespaces in XSLT. This is a known 
limitation but it is still there.
Michael Kay answered the message I posted to the xslt list:
>Date: Tue, 7 Jan 2003 18:49:40 -0000
>From: "Michael Kay" <michael.h.kay@ntlworld.com>
>Subject: RE: [xsl] generating xml with a runtime resolved default namespace
>
>>           I submit to this enlightened list a concrete XSLT
>>  problem for a change. It comes from the need to have a
>>  variable default namespace in the output docu- ment. That is
>>  a default namespace which is known at run-time only.
>
>In XSLT 2.0 there is an <xsl:namespace> instruction that does this.
>
>In 1.0, the workaround is:
>
><xsl:variable name="dummy">
>   <xsl:element name="abc:dummy" namespace="{$var}"/>
></xsl:variable>
>
><xsl:copy-of select="xx:node-set()//namespace::abc"/>

The problem is that this solution does not works with xalan. I have 
thus prefered to not retain it due to the wide availability of Xalan. 
There were possible solution.

Solution 1:
-----------

Adding the default namespace directly in the header:

<!DOCTYPE xsl:stylesheet [
      <!ENTITY owl "http://www.w3.org/2002/7/owl#" >
      <!ENTITY xsd "http://www.w3.org/2000/10/XMLSchema#">
      <!ATTLIST rdf:RDF xmlns "TheCorrectURI#">
    ]>

But I do not know the degree of commitment of RDF/XML and RDF to 
these DOCTYPE statements, so I prefer not to do this.

Solution 2:
-----------

Adding the default namespace like

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:xsd="http://www.w3.org/2000/10/XMLSchema#"
          xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
          xmlns:owl="http://www.w3.org/2002/7/owl#"
          xmlns="TheCorrectURI#">
  ...
</rdf:RDF>

But it involves very dirty XSLT, viz. generating XML through a 
<xsl:text> statement. This should be avoided.

Solution 3:
-----------

This involves adding a default namespace to the "Individual" 
statements which are not owl:Thing typed (xsl:element does not allow 
to define a default namespace which is not that of the current 
element).
This what is implemented in the current stylesheet.

<CheninBlanc xmlns="TheCorrectURI#">
  ...
</CheninBlanc>

This is satisfactory but has the drawback of being re-iterated in 
each such individual.

Possible solution 4:
--------------------

It is quite easy to declare a namespace name and to associate it with 
a namespace à la:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
          xmlns:xsd="http://www.w3.org/2000/10/XMLSchema#"
          xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
          xmlns:owl="http://www.w3.org/2002/7/owl#"
          xmlns:this="TheCorrectURI#">
  ...
  <this:CheninBlanc>
    ...
  </this:CheninBlanc>

</rdf:RDF>

This has not been implemented because it was further away from the 
example in Guide.

Tell me if you have prefereneces or better solutions.

-- 
  Jérôme Euzenat                  __
                                  /      /\
  INRIA Rhône-Alpes,            _/  _   _   _ _    _
                               /_) | ` / ) | \ \  /_)
  655, avenue de l'Europe,    (___/___(_/_/  / /_(_________________
  Montbonnot St Martin,       /        http://www.inrialpes.fr/exmo
  38334 Saint-Ismier cedex,  /          Jerome.Euzenat@inrialpes.fr
  France____________________/                Jerome.Euzenat@free.fr

Received on Friday, 24 January 2003 12:55:27 UTC