Namespace problems

Subject: Namespace problems
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Fri, 1 Sep 2000 09:36:22 +0100
After David C's help, I've been struggling with namespaces.

Background.

The root element of the source document contains

<!ENTITY % URI "CDATA">

<!ELEMENT html (head?, body)>
<!ATTLIST html
  %InternationalAttributes;

  xmlns          %URI;   #FIXED 
  "http://openebook.org/namespaces/oeb-document/1.0/";
  xmlns:xlink   %URI;   #FIXED  "http://www.w3.org/XML/XLink/";
>


With the default template set to

 <xsl:template match="*">
     <xsl:variable name="uri">
    <xsl:choose>
      <xsl:when test="string(namespace-uri())">
	<xsl:value-of select="namespace-uri()"/>
      </xsl:when>
      <xsl:otherwise>Null Namespace</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
    
    ****   Namespace URI is: <xsl:value-of select="$uri"/>
    Declared on element: <xsl:choose>
      <xsl:when test="string(name(..))">
	<xsl:value-of select="name(..)"/>
      </xsl:when>
      <xsl:otherwise>/</xsl:otherwise>
    </xsl:choose>/<xsl:value-of select="name()"/>  ***
  </xsl:template>

(Thanks Mike K, I'll use this in future to trap innocent namespace
errors stopping me dead in my tracks in future)

I get an output of

 ****   Namespace URI is: http://openebook.org/namespaces/oeb-document/1.0/
    Declared on element: //html  ***



However.... when I change the DTD 

<!ELEMENT html (head?, body)>
<!ATTLIST html
  %InternationalAttributes;

  xmlns:oeb          %URI;   #FIXED 
  "http://openebook.org/namespaces/oeb-document/1.0/";
  xmlns:xlink   %URI;   #FIXED  "http://www.w3.org/XML/XLink/";>


The result is, confusingly,
    ****   Namespace URI is: Null Namespace
    Declared on element: //html***

I.e. the namspace is empty (unsure if it is 'null' namespace
or default, but either way there is no namespace.

The root element of the document is html,
which, to get this output, I change to xxx, to ensure
I trap it in the default.

At least I can now find that I'm looking to trigger a 
template which has a namespace when I'm not interested,
but I'm equally sure I don't know why.

Could anyone throw any light on this please.
Using Saxon 5.4

Regards DaveP







 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread