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

Re: Generating namespace declarations given a result tree?

Subject: Re: Generating namespace declarations given a result tree?
From: James Clark <jjc@xxxxxxxxxx>
Date: Thu, 18 May 2000 12:18:58 +0700
Re: Generating namespace declarations given a result tree?
John-Paul Sicotte wrote:

> To this xml
> 
> <element pos = "1"
>   xmlns:jpns1="http://www.messagingdirect.com/xml_namespaces/test1"
>   xmlns:jpns2="http://www.messagingdirect.com/xml_namespaces/test2"
>   xmlns:jpns3="http://www.messagingdirect.com/xml_namespaces/test3"
>   an_attribute = "jpns3:some_function()"
> />
>
> XT gives the following output (I have added whitespace)
> 
> <?xml version="1.0" encoding="utf-8"?>
> <element
>   pos="1"
>   an_attribute="jpns3:some_function()"
> 
>   xmlns:jpns1="http://www.messagingdirect.com/xml_namespaces/test1"
>   xmlns:jpns2="http://www.messagingdirect.com/xml_namespaces/test2"
>   xmlns:jpns3="http://www.messagingdirect.com/xml_namespaces/test3"
> />
> 
> Here none of the namespaces declared in the source tree are actually
> used in the xml so the output has redundant namespace declarations.
> However in this case the namespaces could be used by a meta parser to
> correclty interpret the attribute value.  This is the way xslt works
> with qnames in xpath expressions. XT in this case has also preserved the
> original namespace prefixes.
> 
> My question I guess boils down to this.  Is this just a feature that
> James Clark built into XT to get this extra functionality, or does the
> xslt spec gives some advice on this matter?

XSLT says you're supposed to output a tree T so that if you parsed it
back in again and constructed a tree using the XSLT data mdel you would
get a tree T' that was the same as T except that

- the order of attributes in T' and T may be different
- T' may have namespace nodes that are not in T

See 16.1. (There's a bit of additional complexity to do with document
fragments, but that's not relevant here.)

In this specific case, if you didn't output the namespace declarations
for jpns[1-3] then T would have namespace nodes that T' did not.  That's
not one of the differences that's allowed: XSLT only allows the
converse.  So you must output the namespace declarations for jpns[1-3].

If XSLT didn't do this, it would be difficult to use XSLT to transform
XSLT stylesheets.

Note that there are other kinds of redundancy that XSLT doesn't care
about.  For example:

<foo xmlns:x="abc"><bar xmlns:x="abc"/></foo>

and

<foo xmlns:x="abc"><bar/></foo>

are indistinguishable as far as XSLT are concerned.

James


 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.