Re: [xslt] xsl:element namespace query



On Thu, May 23, 2002 at 07:29:34AM -0400, Daniel Veillard wrote:
> On Thu, May 23, 2002 at 12:08:14PM +0100, Richard Jinks wrote:
> > From: "Daniel Veillard" <veillard@redhat.com>
> > I'll change the code to move the namespace down to the children elements.

Please, don't! There are many situations where this would blow up file 
size dramatically (authogenerated XML, catalog files for example, where all
entries look like:
 <item price="12.90$" vendor:avail="56" > ....
moving the namespace decl. for the vendor prefix down from the parent node
to each item will blow up documents).


> > wrt regenerating declarations, I think I understand what you mean, but just
> > to make sure:
> > 
> > As xmlNodeDumpOutput will always output a namespace prefix if one is
> > defined,
> > either of the following outputs are acceptable:
> > 
> >  <?xml version="1.0" encoding="utf-8"?>
> >  <AAA>
> >     <BBB xmlns="http://zvon.org/xslt";>111</BBB>
> >     <XXX xmlns="http://zvon.org/xslt";>555</XXX>
> >     <XXX xmlns="http://zvon.org/xslt";>555</XXX>
> >  </AAA>
> 
>    Hum, that's a problem in general, if you make the namespace the default one
> this can impact a lot of things. Just imagine that instead of 111 you have
> a QName value in the BBB node, generating a default namespace can alter
> the semantic of the generated content, in ways that are *not* verifiable
> by the XSLT processor. So "generated" namespace prefixes must not be empty
> they really must be as unique as possible !

Yes! And once attributes are used the above approach gets messy, to say the least.

> >  <?xml version="1.0" encoding="utf-8"?>
> >  <AAA>
> >     <ns1:BBB xmlns:ns1="http://zvon.org/xslt";>111</ns1:BBB>
> >     <ns1:XXX xmlns:ns1="http://zvon.org/xslt";>555</ns1:XXX>
> >     <ns1:XXX xmlns:ns1="http://zvon.org/xslt";>555</ns1:XXX>
> >  </AAA>
> 
>   that's fine

but highly verbose. Daniel's version has the same semantics and is way more efficient.

> > In order to keep the qqq: prefix on the last node would require duplicating
> > the namespace node, one with the prefix, one without. It is this that you're
> > not keen on?
> 
>   No, my point is that if one of the parent of the generated node
> hold a declaration for the namespace used then the serialization should
> reuse the associated prefix. If one application relies on the actual
> prefix value and does not check the associated URI then it's simply
> not namespace compliant, please ditch it ! Sorry for being pedantic
> but there are just too many broken code out there (sometimes mine ;-)
> and cleaning the crap is a healthy thing !

Any application relying on the _prefix_ (which is just a pointer to the namespace)
is broken. On the webdav website there's some pretty enlightening information on
the problems created by this. 

> > Any preference to either of the two example styles?
> 
>   Definitely not the first one ! 

Please (<bamni eyes />) keep it the elegant way it is right now.

  Ralf Mattes
> 
> Daniel
> 
> -- 
> Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
> veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
> _______________________________________________
> xslt mailing list, project page http://xmlsoft.org/XSLT/
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]