Re: Namespace problem

Mik Lernout wrote:

>
> Er... correct me if I am wrong but this prefix-in-attributes-thingie 
> is not really related to XMLSchema but rather to XML.
>
I don't see it that way. The XML-Namespaces Recommendation has a section 
on "Applying namespaces to elements and attributes" which talks about 
element and attribute names, as in <foo:bar baz:value="..."/>. It does 
not talk on the use of namespaces (via prefixes) in content, which is 
therefore special. XML Schema makes use of prefixes in a "special" way, 
which makes implementation slightly harder.

> The basic idea is that in any location in an XML file there is always 
> a namespace context: a mapping of prefixes to namespaces. The usage of 
> this mapping in element names or in attribute names/values does not 
> really matter. Even the actual value of the prefix is not really 
> important, it is what namespace it represents in that specific spot of 
> the XML file....
>
OK, seen as a stream of characters, you are probably right. However, I 
like to think of XML in terms of a "core" Infoset (strictly less than 
Infoset, namespace prefixes should not be part of it): An XML document 
is a labelled tree, with labels being URI:name pairs. This simple view 
works for most XML documents, however, for the above reasons, it does 
not work for XML Schema - one has to remember the prefixes.

This dependence on prefixes has direct influence on how to design an XML 
API... if you include prefix mappings in a tree model, it becomes larger 
(every tree node needs to have the possibility to store prefix-URI 
mappings).

cheers,
Burak

> Mik
>
> PS: You mentioned that you are working on schema validator, in which 
> language is it and is it open source? I am also doing one in java and 
> maybe we could merge some work...
>
I am writing a data binding tool for Scala, http://scala.epfl.ch. Surely 
we can exchange some information (maybe the list is not the best place 
for that, though). My design of Scala's XML API follows the above principle.

>
> Burak Emir wrote:
>
>>
>> Hello Volker,
>>
>> 1. which parser are you using? Is it possible that is has 
>> namespace-support disabled?
>>
>> 2. [unsure] does it work when you remove the "plem:" prefix from the 
>> schema (both in root and in the type="plem:" attribute) ?
>>
>> I am implementing a schema validator myself, and I stubbed my toe on 
>> a similar thing. The fact is, common sense would suggest namespaces 
>> make element names unique by adding the URI to them. It would then be 
>> ok to forget the namespace prefixes, representing element names as 
>> {uri:name}.
>>
>> Unfortunately, in XML schema this is not the entire truth - one has 
>> to remember also the prefixes, because they appear in attribute 
>> values. I consider this a real shortcoming of the XML schema 
>> definition language - it is counter-intuitive, because one is forced 
>> to mix the structure of the definition (a declaration xmlns:foo="..." 
>> in the root element <schema ...>) with the structure of the instances 
>> (as in type="foo:...").
>>
>> Since there is no element "plem:...", it could be that your software 
>> just "forgot" about that prefix, and defaulted it to "" - in any 
>> case, a bug.
>>
>> cheers,
>> Burak
>

Received on Wednesday, 18 August 2004 09:27:33 UTC