W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2000

Re: Schema and ANY questions

From: Curt Arnold <carnold@houston.rr.com>
Date: Fri, 21 Jul 2000 09:58:59 -0500
Message-ID: <002d01bff324$335a6e80$b444a018@houston.rr.com>
To: <xerces-j-dev@xml.apache.org>
Cc: <www-xml-schema-comments@w3.org>
I've crossposted this response (which includes your message originally
posted on xerces-j-dev@xml.apache.org) to www-xml-schema-comments@w3.org
(see http://www.w3.org/Mail/Request for subscription info).  The W3C
comments
list is the best forum for comments on the spec itself and not just the
Xerces implementation of it.

I had some of the questions myself about how the <any> element
deals with elements that are not in any namespace, but I hadn't looked
throughly enough to formulate a comment.  The use of ##local to represent
an element that is not associated with a namespace is probably a poor choice
of words.
I would have thought ##unqualified or ##namespaceAbsent would be clearer and
mimimize confusion with ##targetNamespace.

I'm not sure what you mean in question 2 about "encoding".  Typically that
word is
used to indicate how characters are represented in memory or on disk, such
as an
particular code page, EBCDIC, UTF-8, UTF-16, etc.  You could on the element
that has an <any/> particle in its content model specify an "xsi:type" that
indicated
a more restricted content model should be used for validation.

In question 3, I don't see why that would be a problem.  Maybe I
misunderstand
your questions.

You schema from part 4 is not valid due to the a violation of the
Unique Particle Attribution requirement that says that it not legal to
have a schema where one element could potentially be attributed to two
particles of the
content model.  Since a <trn:A> element could both satisfy the explicit
element particle or the any particle, the schema isn't valid.

>     <schema ... targetNamespace="URI_TNS" xmlns:tns="URI_TNS">
>     <element name="A" type="string"/>
>     <element name="B">
>       <complexType>
>         <element ref="tns:A" minOccurs="0" maxOccurs="1"/>
>         <any namespace="##targetNamespace" minOccurs="1" maxOccurs="1"
>              processContents="strict"/>
>      </complexType>
>     </element>
>     </schema>


This one could be rewritten equivalently without the <element ref="tns:A">
particle.

>     <schema ... targetNamespace="URI_TNS" xmlns:tns="URI_TNS">
>     <element name="A" type="string"/>
>     <element name="B">
>       <complexType>
>         <any namespace="##targetNamespace" minOccurs="1" maxOccurs="2"
>              processContents="strict"/>
>      </complexType>
>     </element>
>     </schema>

I have suggested an <exclude> child element for any that would allow you to
specifically exclude a particular name from matching an <any> particle.

------------------

Original message on xerces-j-dev@xml.apache.org

Subject:
          Schema and ANY questions
     Date:
          Fri, 21 Jul 2000 14:30:18 +0200
     From:
          "Jean-Louis Vila" <jlvila@cosmosbay.com>
 Reply-To:
          xerces-j-dev@xml.apache.org, <jlvila@cosmosbay.com>
       To:
          "Mailing list Xerces-J" <xerces-j-dev@xml.apache.org>




Hi,
I work since severals weeks on Schema structure&datatypes.

Many interrogations raise when I read WD 4/7 about "any" element.

1 - I found rules about any & namespaces very vague !
2 - When I define an ANY element in my Schema,
    in the instance document,how can we specify
    the encoding of the input fragment XML ?
3 - I guess that validating a schema instance with no targetNamespace
    and an any element with namespace="##local" will be
    impossible to realized!!
    I don't find any rule about this case.
4 - Case of schema defined with a targetNamespace and an "any"
    element defined with namespace="##targetNamespace"
    In an instance document, how can we detect that an element come from
    "any" element or an element explicitly defined in the schema ?
    Ex:
        ----Here the schema----
    <schema ... targetNamespace="URI_TNS" xmlns:tns="URI_TNS">
    <element name="A" type="string"/>
    <element name="B">
      <complexType>
        <element ref="tns:A" minOccurs="0" maxOccurs="1"/>
        <any namespace="##targetNamespace" minOccurs="1" maxOccurs="1"
             processContents="strict"/>
     </complexType>
    </element>
    </schema>
        ----Here an instance schema----
     <A>
       <B/> <!-- B is come from "any" or is it the first element of "A"
? -->
     </A>

        Results:
         . if B is the first element of "A", this instance is non-valid.
         . if B is the root element of "any", this instance is valid.
     Here is the problem !
     The only way to solve this problem, is to consider the "any" XML
document as
     self-supporting XML document. In this way, the "B" element will contain
     the definition of namespace in it (xmlns attribute).
     ----Ex1----
     <A>
       <B/> <!-- Here B is the first element of "A"
     </A>
        ----Ex2----
     <A>
       <B xmlns="URI_TNS"/> <!-- Here B is the root element of "any"
element -->
     </A>

    So we can say:
         Ex1 --> non-valid
         Ex2 --> valid

Any opinions will be appreciated,
Jean-Louis Vila

C o s m o s  B a y
    L'Esprit
          Système Internet

84, rue du 1er mars 1943
69625 Villeurbanne Cedex - France
tel +33 (0)4.72.65.21.00
fax +33 (0)4.78.85.58.24
Received on Friday, 21 July 2000 11:18:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:49:53 UTC