[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Namespace problems

Subject: Namespace problems
From: "Pawson, David" <DPawson@xxxxxxxxxxx>
Date: Fri, 1 Sep 2000 09:36:22 +0100
namespace problems
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.