Re: [xml] XSLT II

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Tue Dec 21 1999 - 09:40:18 EST


On Tue, Dec 21, 1999 at 02:33:24PM +0100, Mathias Hasselmann wrote:
>
> Daniel Veillard wrote:
> >
> > On Tue, Dec 21, 1999 at 02:03:13AM +0100, Mathias Hasselmann wrote:
> > >
> > > Pardon to all xml-list recipients:
> > > The mail with subject "XSLT" was addressed toward Daniel...
> > > But my address book seems to be wracked...
> > >
> > > BUT while playing around with XSLT I've found a misbehavior of libxml.
> > >
> > > When parsing a the W3C XSLT/doc-example which starts with:
> > >
> > > <xsl:stylesheet version="1.0"
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > > xmlns="http://www.w3.org/TR/xhtml1/strict">
> > > ...
> > >
> > > the call
> > > xmlGetNsProp (stylesheet->root, "version",
> > > "http://www.w3.org/1999/XSL/Transform"),
> > > returns NULL.
> > You didn't tell which version of the library you used,
> > libxml-1.8.0 broke default namespaces support :-( that's the reason
> > why i released libxml-1.8.1 (which in turn has troubles with C++ so I
> > expect to release libxml-1.8.2 today :-( ))
> >
> > So one easy answer may be 'upgrade', tell me if you still have troubles.
> >
>
> I tried with 1.8.1...
>
> But after rereading W3C's namespace-specs and trying
>
> xmlGetNsProp (stylesheet->root, "xsl:version", ...
>
> which returns "1.0" I'm confused:
>
> Is libxml or W3C's example invalid?

 Well in the example:
   - the default namespace for the element is http://www.w3.org/TR/xhtml1/strict
   - but the element namespace is http://www.w3.org/1999/XSL/Transform
since the version attribute was not prefixed it's not obvious to which
namespace it belongs, so let's go back to the root:

------------ Section 5.2 Namespace Defaulting, first paragraph
A default namespace is considered to apply to the element [...].
Note that default namespaces do not apply directly to attributes.
------------

  Bingo,

~/XML -> gdb tester
[...]
(gdb) r --debug ns.xml
Starting program: /u/veillard/XML/tester --debug ns.xml
DOCUMENT
version=1.0
standalone=true
  ELEMENT xsl:stylesheet
    namespace xsl href=http://www.w3.org/1999/XSL/Transform
    default namespace href=http://www.w3.org/TR/xhtml1/strict

Breakpoint 1, xmlDebugDumpAttr (output=0x40115c60, attr=0x80861e8, depth=2)
    at debugXML.c:103
103 for (i = 0;((i < depth) && (i < 25));i++)
(gdb) p *attr
$1 = {_private = 0x0, vepv = 0x0, type = XML_ATTRIBUTE_NODE, node = 0x8085fd0,
  next = 0x0, name = 0x8086230 "version", val = 0x8086260, ns = 0x8086168}
(gdb) p *attr->ns
$2 = {next = 0x0, type = XML_LOCAL_NAMESPACE,
  href = 0x80861a0 "http://www.w3.org/TR/xhtml1/strict", prefix = 0x0}
(gdb)

  So this is a BUG !
The mistake was to try to apply the default namespace rule built for elements
to attributes too.

Rereading the namespace specification it is also clear that an attribute
without prefix uses the namespace from the element carrying it.

So the example is right (one could have assumed that :-),
an libxml needed to be fixed. It seems to be working fine now:

Breakpoint 1, xmlDebugDumpAttr (output=0x40115c60, attr=0x8086208, depth=2)
    at debugXML.c:103
103 for (i = 0;((i < depth) && (i < 25));i++)
(gdb) p *attr->node->ns
$1 = {next = 0x8086188, type = XML_LOCAL_NAMESPACE,
  href = 0x8086110 "http://www.w3.org/1999/XSL/Transform",
  prefix = 0x8086160 "xsl"}
(gdb) call xmlGetNsProp(attr->node, "version", "http://www.w3.org/1999/XSL/Transform")
$2 = (xmlChar *) 0x8085c60 "1.0"
(gdb)

  I'm about to release 1.8.2, this will be corrected,

Daniel

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | Today's Bookmarks :
Tel : +33 476 615 257  | 655, avenue de l'Europe | Linux XML libxml WWW
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Gnome rpm2html rpmfind
 http://www.w3.org/People/all#veillard%40w3.org  | RPM badminton Kaffe
----
Message from the list xml@xmlsoft.org
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@xmlsoft.org


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:29:55 EDT