473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Default namespace and attributes

I am curious as to the rationale, and effect, of having default
namespaces not applying (directly) to attributes (see
http://www.w3.org/TR/REC-xml-names/#defaulting). Given an attribute
without a namespace prefix, what is its namespace, if default
namespaces do not apply? Are (either of) prefixed or non-prefixed
attributes correct? For example, are the following equivalent:

<html:br class="foo" xmlns:html="http://www.w3.org/1999/xhtml"/>

and

<html:br html:class="foo"
xmlns:html="http://www.w3.org/1999/xhtml"/>

If so, why? In the former, the class has no (or an empty?) namespace,
while in the latter the class explicitly has the html namespace.

Why would it make sense for attributes to not inherit namespaces as do
elements? What does the specification mean when it says that default
namespaces do not apply /directly/ to attributes?

While I'm on the topic of namespaces, another little thing has been
gnawing at the back of my brain. How can you determine when an
included, namespace-scoped subtree is allowed to be included into the
parent? For example:

<html:html xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:other="http://some.other.namespace/">
<!--Other elements to make the xhtml file valid can be put
here...-->
<other:foo/>
</html:html>

Now, obviously schemas corresponding to the html namespace have no
knowledge of the "other" namespace, and so "other" elements shouldn't
be allowed to arbitrarily populate an "html" tree. Where in the
specifications is this sort of thing discussed? Are subtrees of one
namespace invisible to the parent tree of a different namespace?

Ok, true, this should really have been broken up into two threads, but
I was on a roll, so I felt like just cruisin' through them both.

Take care,

John

--

Please note that you have no evidence that this message was sent by me
<jl**@po.cwru.edu>, as it is not digitally signed. If you need to
validate the authenticity of this message, do not hesitate to request
a receipt by responding to this message with the original included.
Jul 20 '05 #1
1 2679
jl**@po.cwru.edu (John L. Clark) writes:
I am curious as to the rationale, and effect, of having default
namespaces not applying (directly) to attributes (see
http://www.w3.org/TR/REC-xml-names/#defaulting).
Good question. Consider the following:

- In most XML vocabularies, attributes are defined for
specific element types, not globally for the vocabulary.
- There are, however, exceptions: attributes intended for
use on arbitrary elements (and meaningful even if used
on elements in other namespaces).
- If one takes the term 'namespace' as denoting a pool of
identifiers which each uniquely denote some thing (e.g.
locations in memory or functions), then it's clear that
any XML vocabulary defined by a DTD has several distinct
namespace: one for element types, one for general
entities, one for parameter entities, and so on. Each
element type, in turn, creates a distinct namespace for
its attributes. On this understanding, it's clear that
in the element <foo bar="baz"/>, the element type name 'foo'
and the attribute name 'bar' are in distinct namespaces.
Crucially, the 'bar' attribute of element 'foo' is
quite distinct from the 'bar' attribute of any other element
which might have one: different declaration, possibly
different type, etc.
- It seemed cumbersome but reasonable to require a prefix
on the generic identifier (so we get <n:foo/>), but requiring
a prefix on all the attributes as well seemed problematic:
is it the same namespace? Not if a 'namespace' is a
functional mapping from names to things: the 'bar'
attribute of 'foo' is quite distinct from any 'bar' element
which may be defined in the same vocabulary.
Is it a different namespace? Well, not if we think of
a namespace as containing, or being, a single vocabulary.
And if we did make it a different namespace, then we'd
end up needing a distinct prefix for the attribute namespace
of each element. That, in turn, didn't seem attractive
to anybody.
- If we want to distinguish global from local attributes, it's
convenient to say that local ones are always unprefixed,
and global ones always prefixed.

Given that the Working Group did not have any consensus on the nature
of a 'namespace', nor any consensus about the desirability of greater
clarity on the question, it is perhaps not surprising that we ended up
by agreeing on something which has two rather different
interpretations. We agreed that unprefixed attribute names are not
namespace-qualified (if I may use these terms). Some WG members
believed, I think, that that means "the attributes are not in any
namespace", although there is nothing in the Namespaces spec which
licenses the conclusion that unqualified elements and attributes are
"not in a namespace". (All one can say is that the Namespace mechanism
doesn't associate them with a namespace. Since the spec doesn't
define what a namespace is or constrain it in any way, there isn't
much opportunity for it to say that an unqualified item cannot be
known by out of band methods to be "in" some namespace or other.)
Other WG members believed, I think, that the attributes are "in" the
namespace (or symbol space, as the XML Schema spec calls it)
automatically created for the attributes of each element type; that
namespace is not named, and nothing in the Namespaces Rec says much
about it, but that means nothing in the Namespaces Rec can be used to
prove that it doesn't exist.

So, the main rationale and effect of the rule was to allow the WG to
get the spec out the door before we killed each other or died of
boredom with repetitive arguments.
Given an attribute without a namespace prefix, what is its
namespace, if default namespaces do not apply?
It is not associated by the namespace spec with any namespace. This
means (depending on whom you are talking to) either that it is not in
any namespace or that its association, if any, with a namespace is
achieved through means other than those defined in the namespaces
spec.
Are (either of) prefixed or non-prefixed
attributes correct? For example, are the following equivalent:

<html:br class="foo" xmlns:html="http://www.w3.org/1999/xhtml"/>

and

<html:br html:class="foo"
xmlns:html="http://www.w3.org/1999/xhtml"/>
Not equivalent: the universal names of the two 'class' attributes are
different. One has the pair ("http://www.w3.org/1999/xhtml","class")
as its universal name, the other the pair (NULL, "class"), where NULL
signals the non-existence of a value.
While I'm on the topic of namespaces, another little thing has been
gnawing at the back of my brain. How can you determine when an
included, namespace-scoped subtree is allowed to be included into the
parent? For example:

<html:html xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:other="http://some.other.namespace/">
<!--Other elements to make the xhtml file valid can be put
here...-->
<other:foo/>
</html:html>

Now, obviously schemas corresponding to the html namespace have no
knowledge of the "other" namespace,
How is this obvious? What is to prevent a schema from including
components for both the html and the 'other' namespace? What is to
prevent the content model for the html element from including a
reference to the 'other:foo' element type?
and so "other" elements shouldn't
be allowed to arbitrarily populate an "html" tree. Where in the
specifications is this sort of thing discussed?
The mechanisms by which a schema can comprise components for more than
one namespace are described in the XML Schema specification. The
specifics of what can occur in an HTML element, or in any element in
any namespace, are discussed (if at all) in the documentation for the
namespace in question and defined in the schema documents or DTDs for
that namespace.
Are subtrees of one
namespace invisible to the parent tree of a different namespace?


At the application level, they can be. At the XML level, or the
level of validation using current schema languages, no, not
invisible at all.

I hope this helps.

-C. M. Sperberg-McQueen
World Wide Web Consortium
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: kj | last post by:
Consider the following XML document: <?xml version='1.0' encoding='UTF-8'?> <bar:foo xmlns:bar='someuri'> <baz/> </bar:foo> What namespace does baz belong to? What is this namespace bound...
1
by: indo3 | last post by:
HELLO For the top root element of my schema file, i want to declare following attribute: <xs:attribute name="xmlns:m" type="xs:string" default="http://www.w3.org/1998/Math/MathML"/> But...
4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
6
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a...
2
by: VanOrton | last post by:
Hi all, When XercesDOMParser parses an XML document with a Schema instance, by default it adds all missing default and fixed attributes. I have the impression though that it misses the...
4
by: Samuel R. Neff | last post by:
I'm writing an xslt in vs.net 2003 and in order to get intellisense on the html content I added the default namespace declaration xmlns="http://schemas.microsoft.com/intellisense/ie5". However,...
7
by: Bilal | last post by:
Hello all, I came across this problem while working out the bugs in my identity trasnformation stylesheets but sidestepped it for later to see if there is an easier/better solution. This is...
9
by: Mark Olbert | last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c. The problem I'm running into is that the root element needs to be unqualified,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.