p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   undeclare-namespaces directive (http://p2p.wrox.com/showthread.php?t=68115)

mphare May 14th, 2008 10:48 AM

undeclare-namespaces directive
I'm using Saxon8B within the Oxygen XML IDE.
I'm also neck deep in having to deal with <!ENTITY ...> references because my XML source came from heavily SGML'd Framemaker, and they still use <!ENTITY ...> for referencing bitmaps.

So I'm using the saxon extensions for generating these items.

But the problem is that I've defined the namespaces for the saxon extensions and the dtd extensions and these namespaces are showing up in my result tree.

In "XSLT 2.0" on or about page 114 in Capter 3, section "Namespaces for a Literal Result Element" there is a note that one can use:


quote:<xsl:output method="xml" version="1.1" undeclare-namespaces="yes"/>

and then use something like:


quote:<img xmlns:saxon="" xmlns:dtd="" href="{unparsed-entity-uri(.)}"></img>

to remove these unwanted and unneeded namespaces in the result.

Problem is I'm getting an error:


quote:Severity and Description Path Resource Location Creation Time Id

[Saxon8B] Attribute @undeclare-namespaces is not allowed on element <xsl:output>
@see: http://www.w3.org/TR/xslt20/#err-XTSE0090
The w3c link confirms this to be a static error and further indicates to use exclude-result-prefixes attributes to stop the unwanted namespaces in the result tree.

However, I declared the extension namespaces on the global <xsl:stylesheet> element. I don't seem to be able to add the exclude-result-prefixes to the global element.

How else can I remove these unwanted namespaces from my result tree?

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare

samjudson May 14th, 2008 10:53 AM

Why can't you use exclude-result-prefixes="saxon"? That should work fine.

Also try extension-element-prefixes="saxon".


<xsl:stylesheet extension-element-prefixes="saxon" exclude-result-prefixes="saxon">

/- Sam Judson : Wrox Technical Editor -/

mhkay May 14th, 2008 10:56 AM

The attribute name on xsl:output changed from undeclare-namespaces to undeclare-prefixes in the final specification.

However, this attribute is quite irrevelant to your requirement.

You want something like this:

<xsl:stylesheet version="2.0"
  exclude-result-prefixes="xs saxon">

If you prefer to declare the namespaces locally you can also exclude them locally:

<img xmlns:saxon="http://saxon.sf.net/"
    xsl:exclude-result-prefixes="saxon" href="..."/>

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference

mphare May 14th, 2008 11:16 AM

I must have entered the attribute wrong, because I did try it and got a parsing error.

I tried again and it works just fine .. Thanks!

GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876

Michael Hare

All times are GMT -4. The time now is 11:29 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.