Re: [xml-dev] Namespaces in XML and schemas

>-------Original Message-------
>
>From: <mailto:rpbourret@rpbourret.com>Ronald Bourret
>Date: Thursday, January 31, 2002 12:11:00 AM
>To: <mailto:laurent@AscianTech.com>Laurent Therond
>Cc: <mailto:xml-dev@lists.xml.org>xml-dev@lists.xml.org; 
><mailto:xmlschema-dev@w3.org>xmlschema-dev@w3.org
>Subject: Re: [xml-dev] Namespaces in XML and schemas
>
>Laurent Therond wrote:
>
> > This could be a stupid question,
>
>It definitely isn't.
>
> > "Namespaces in XML" states:
> >
><snip />
>
> > Hence, in accordance with the specification of namespaces, the following
> > document (a stylesheet fragment) is said to be valid (I am not sure if
> > "valid" applies here, in fact.):
>
>I think you are confusing three different things:


That's very possible! :-)


>1) Conformance to the namespaces spec. The following document conforms
>to the namespaces spec.


I understand that.


>2) Validity. Technically, this means that a document is valid according
>to a DTD. The following document is not valid because it does not
>contain a DTD, so validity can't be checked. You could write a DTD for
>this specific document, but there is no reason to do so, as it wouldn't
>apply to other similar (but different) XSLT documents. It is impossible
>to write a DTD that applies to all XSLT documents, since XSLT documents
>can contain arbitrary elements.


I was not implying validity in that sense.
After reading your answer, I now understand that I was talking about schema 
validity.
In my mind, asking "Is it valid?" was equivalent to asking "Can this 
document be obtained as a production of the grammar defined by merging the 
specified schemas?".


>3) Schema validity. This means that a document is valid according to an
>XML Schema. It is (theoretically) possible to schema-validate only part
>of a document. It is also possible to "laxly" schema-validate documents
>or skip parts of documents altogether during schema validation. These
>might be useful for validating XSLT stylesheets (see below).
>
>Other schema languages have similar types of validity. The rules vary
>according to the language.


In the case I presented, schema validation is not possible whether you use 
the assumed schema for XHTML or the assumed schema for XSLT.

After reading your explanation, I conclude this stylesheet cannot be 
validated (no DTD) and it cannot be schema validated either (contradictory 
schemas).


>An interesting question here is whether it is possible to write:
>
>a) A schema (any language) to validate the XSLT parts of an XSLT
>document,
>
>b) A schema (any language) to validate the non-XSLT parts of an XSLT
>document for a given output type (e.g. the output of the XSLT schema
>must be XHTML).
>
>Any takers?
>
><snip text="XSLT document" />
>
> > Now, this is swell and all but an assumed schema for XHTML would not allow
> > the "xsl:value-of" element as part of the content of the "title" element.
>
>Correct.
>
> > Therefore, my questions are:
> >
> > 1) Are stylesheets supposed to be valid documents?
>
>No. See above.
>
> > 2) How can one consider the possibility of multischema documents, granted
> > that 2 schemas can conflict with each other?
>
>Depends what you mean by multi-schema documents:


If a document contains elements belonging to 2 different namespaces, if 
these 2 different namespaces are inherent to 2 different schemas, then the 
concept of validity cannot directly be applied to such document.


>1) A document, all of which conforms to more than one schema. Although
>it is possible to write an infinite number of schemas that apply to a
>single document, it would be very rare to do so.
>
>2) A document, parts of which conform to different schemas. This is more
>common, although still a minority. XML Schemas allows you to define such
>schemas to a certain extent. When you get to the part of the document
>outside the current schema, you simply say, "Anything can go here."
>(This works for children. Does XML Schemas have a way to say, "I can
>have any parent, but I must conform to the following schema?")
>
>3) A document whose schema has elements/attributes from more than one
>namespace. This is the most common case and is supported by all schema
>languages. Namespaces are used to resolve collisions between local
>names.


The fact of the matter is: The XHTML specification (for instance) is normative.
I cannot teach the XHTML schema to understand that element type 
yaml:variable (defined by the YAML schema) is OK as part of the content of 
the title element type. Isn't that true?

e.g., if I try to schema validate a XHTML document that contains the following:

<title>This is my <yaml:variable name="title"/></title>

...any editor capable of performing schema validation will complain about 
this <yaml:variable name="title"/> where PCDATA is expected...


> > Finally, I am asking these questions because I would like to define the
> > schema of a minimal language that I would use to create document templates.
> > Among other things, this minimal language would involve elements that are
> > not allowed as part of the content of certain XHTML (for instance)
> > elements, but that must exists as such to provided the desired templating
> > functionality.
>
>The short answer is that you won't be able to use the XHTML schema (for
>example) to validate such documents. Whether it is possible to use the
>XHTML schema to partially validate such documents probably depends on
>how you want to use XHTML.


Exactly my conclusion!
I will probably have to start with the XHTML schema, add the elements of my 
template language to it, alter the XHTML schema to allow my template 
language elements in all necessary places, and finally designated the 
resulting extended schema as the true schema of my template language.


>-- Ron
>
>.


Thanks again, Ron, for taking the time to answer my questions.
If you have further feedback on my crazy interpretations, please do not 
hesitate to reply to this note.

Regards,

L.

Received on Thursday, 31 January 2002 14:00:55 UTC