[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] My report on experiments with unused namespaces
- From: David Carlisle <davidc@nag.co.uk>
- To: "Costello, Roger L." <costello@mitre.org>
- Date: Wed, 15 Sep 2010 23:05:43 +0100
On 15/09/2010 22:45, Costello, Roger L. wrote:
> David Carlisle wrote:
>
>> According to your definition of "unused" almost every XSLT stylesheet,
>> and a large proportion of XSD schema and RelaxNG schema use unused
>> namespaces. Are they all evil?
>
> You are correct David. My definition of both "used" and "unused" namespace needs updating.
>
> Here goes.
>
> [Definition] Used Namespace: a namespace in an XML instance document which is
>
> (1) used in an element name, or
>
> (2) used in an attribute name, or
>
> (3) used in a QName of an attribute value, or
>
> (4) used in a QName of an element value.
>
> Example: This XML document illustrates the 4 locations where namespaces may be used:
>
> <Root xmlns:NS1="http://www.namespaces.org/1"
> xmlns:NS2="http://www.namespaces.org/2"
> xmlns:NS3="http://www.namespaces.org/3"
> xmlns:NS4="http://www.namespaces.org/4">
>
> <NS1:child NS2:attr="NS3:att-value">
> NS4:elem-value
> </NS1:child>
>
> </Root>
>
> [Definition] Unused Namespace: a namespace in an XML instance document which is
>
> (1) not used in an element name, and
>
> (2) not used in an attribute name, and
>
> (3) not used in a QName of an attribute value, and
>
> (4) not used in a QName of an element value.
>
> Example: In the following XML document this namespace is not used: http://www.namespaces.org/5
>
> <Root xmlns:NS1="http://www.namespaces.org/1"
> xmlns:NS2="http://www.namespaces.org/2"
> xmlns:NS3="http://www.namespaces.org/3"
> xmlns:NS4="http://www.namespaces.org/4"
> xmlns:NS5="http://www.namespaces.org/5">
>
> <NS1:child NS2:attr="NS3:att-value>
> NS4:elem-value
> </NS1:child>
>
> </Root>
>
> Do you agree?
No.
>
> Have I identified all the locations where namespaces may be used?
No.
>
> /Roger
Firstly you haven't really defined your terms.
I'd think that by
3) used in a QName of an attribute value, or
you mean attributes typed as QName, but that doesn't include any
attributes that take xpath or any other language that include qnames.
So the best you could say is that the namespace declaration
xmlns:foo=... is unused if the string foo: does not occur as a substring
of any element or attribute, but again that misses lots of important uses.
consider
<xsl:element name="{a/b/c}">
now if the string value of the xpath a/b/c evaluated at the current node
is "x:y" then this will only work if there is a namespace declaration
for the prefix x in scope at this point of the stylesheet so
a declaration xmlns:x="..." something is required even though the string
x: never appears in any element or attribute content.
So the stylesheet with such an expression needs to have namespace
declarations for _all_ namespace prefixes that could be picked up from
_any_ input document.
You could try to special case attribute value templates in your
definition of "unused" but the same might be true of any xml vocabulary
perhaps the run time behaviour of NS1:child in your example is similar
to xsl:element and it uses all the in scope namespaces in non trivial
ways whether or not the use is explicit in the source.
the namespace rec does not define "unused namespace" and there seems
little point in trying to define it in general. Like "unused comment"
or "unused document" it may have meaning in certain restricted
circumstances but not in general.
David
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]