W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: How to represent fixed namespace attributes?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 23 Feb 2002 22:48:45 +0000
Message-ID: <13523156717.20020223224845@jenitennison.com>
To: "Pete Beazley" <pete@clearlyonline.com>
CC: xmlschema-dev@w3.org
Hi Pete,

> Is it possible to represent fixed namespace attributes using XML
> Schema? For example, what would the equivalent of the following DTD
> fragment be in XML Schema?
> <!ELEMENT rdf:RDF (rdf:Description*)>
>   xmlns:rdf     CDATA #FIXED
> "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>   xmlns:dc      CDATA #FIXED "http://purl.org/dc/elements/1.1/"
>   xmlns:dcterms CDATA #FIXED "http://purl.org/dc/terms/"
> I'm struggling to see a way to do this in XML Schema since the
> <xsd:attribute> element doesn't allow namespace qualified attribute
> names to be declared. And, I don't believe it is legal to declare
> 'xmlns' as a namespace since it is reserved by XML.

I just wanted to clarify what you're aiming to do here, since fixing
namespace declarations using ATTLIST declarations in a DTD really has
three outcomes:

 - it ensures that the RDF element is in the RDF namespace (and that
   the various Dublin Core elements are in the Dublin Core namespaces)

 - it ensures that the RDF namespace uses the prefix 'rdf' (and that
   the two Dublin Core namespaces use the prefixes 'dc' and 'dcterms')

 - it allows an instance document to omit the namespace declarations
   and still be treated in the same way by a validating parser
The second outcome is generally, in a namespace-aware world, a bad
thing. One of the desirable features of namespaces is that a
individual document can use whatever prefix it likes for a particular
namespace without changing the meaning of the document.

The third outcome is also a bad thing in a namespace-aware world,
because if you don't use a validating parser or if the DTD is missing
for some reason, the prefixes in the document become unresolvable and
therefore the document becomes unreadable to any namespace-aware

So if you're concerned about being able to fix the namespace
declaration attributes for either the second or third reason, I
suggest that you stop worrying - let people use whatever prefix they
like, and do ensure that people declare the namespaces in the instance
document itself, so that it doesn't matter if the DTD goes missing. (If
you *do* care for some reason, then you have to stick with the DTD, as
Eric stated.)

And that means that all you're actually left to worry about is whether
the schema declares that the RDF element is in the RDF namespace; to
do that, you need to have a schema that has the RDF namespace as the
target namespace, and make sure that you import the Dublin Core
namespaces (even if you don't actually have schemas for them):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

<xs:import namespace="http://purl.org/dc/elements/1.1/" />
<xs:import namespace="http://purl.org/dc/terms/" />

<xs:element name="RDF">
      <xs:element name="Description" type="rdf:DescriptionType"
                  minOccurs="0" maxOccurs="unbounded" />

<xs:complexType name="DescriptionType">...</xs:complexType>



To be a valid instance document against its schema, the document will
have to have an RDF element in the RDF namespace as its document
element. It doesn't matter what prefix they use, but the author has to
declare the namespace with a namespace declaration on the RDF element.
For example, the following instance documents are schema valid:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />

<r:RDF xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />

But the following documents are schema invalid:

<rdf:RDF />

<rdf:RDF xmlns:rdf="http://www.nonRDF.namespace.com/" />



Jeni Tennison
Received on Saturday, 23 February 2002 17:48:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:59 UTC