You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jean-Louis Vila <jl...@cosmosbay.com> on 2000/07/21 14:30:18 UTC
Schema and ANY questions
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
Re: Schema and ANY questions
Posted by Eric Ye <er...@locus.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 ?
Why do you need to do that? the element from another namespace is just a
elment with
different namespace prefix, has to be physically appears in the same
instance document including
all its content.
> 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.
I didn't either,
> 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>
>
This not not valid since A's content is of type "string", which can't have
element content at all.
Perhaps you meant:
<B>
<A/> <!-- A is come from "any" or is it the first element of "B"
? -->
</B>
in this case, the ACTUAL children of B element , which contains just a A
element, matches the content model of declared B , which is (A?,
any##targetNamespace?). It should match the first A? as far as I can rember.
Furthermore, it seems doesn't matter which one is actually matched.
> 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>
>
Totally confused.....
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org