Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: abstract elements and xsi:type substitution

From: "Michael Kay" <mike@--------.--->
To: "'Stan Kitsis'" <skits@---------.--->, <xmlschema-dev@--.--->
Date: 1/11/2006 10:01:00 AM
This is what Saxon says on the matter:
 
Validation error on line 9 column 32 of file:/c:/temp/test.xml:
  Invalid element <Item>: the element is declared to be abstract
Validation of source document failed
 
However, the schema spec doesn't give you a simple boolean function
isValid(instance, schema). For example in 3.3.4 Element Locally Valid
(Element) we read:
 
For an element information item to be locally
<http://www.w3.org/TR/xmlschema-1/#key-vn> =B7valid=B7 with respect to =
an
element declaration all of the following must be true: 
1 The declaration must not be  =
<http://www.w3.org/TR/xmlschema-1/#key-null>
=B7absent=B7.
2 Its  <http://www.w3.org/TR/xmlschema-1/#e-abstract> {abstract} must be
false.
3 ...
 
So it's clear that your Item element is not locally valid with respect =
to
this element declaration.
 
But from 3.3.4 Element Locally Valid (Type) we can see that the element =
is
locally valid with respect to the type xs:string.
 
In 5.2 we see that there are three ("primary") ways of assessing the
schema-validity of an element. Method 1 allows you to ask "is Item a =
valid
xs:string", and the answer is yes. Method 2 allows you to ask "is Item a
valid Item", and the answer is no. Method 3 allows you to ask "is Item
valid?" - which is closest to your question, and what the spec says is:
 
"The processor starts from
<http://www.w3.org/TR/xmlschema-1/#cvc-assess-elt> Schema-Validity
Assessment (Element) (=A73.3.4) with no stipulated declaration or =
definition,
and either  <http://www.w3.org/TR/xmlschema-1/#key-sva> =B7strict=B7 or
<http://www.w3.org/TR/xmlschema-1/#key-lva> =B7lax=B7 assessment ensues,
depending on whether or not the element information and the schema =
determine
either an element declaration (by name) or a type definition (via =
xsi:type)
or not."
 
Schema-Validity Assessment (Element) clause 1 says that "for =
schema-validity
to be assessed", *either* 1.1 or 1.2 must be true. 1.1 is true if the
element is valid against the element declaration; 1.2 is true if it is =
valid
against the xsi:type. This suggests that the element has to be valid =
against
either the element declaration or the xsi:type, but not necessarily =
against
both.
 
What's more, there's a note: "Note: In general if clause
<http://www.w3.org/TR/xmlschema-1/#c-ed> 1.1 above holds clause
<http://www.w3.org/TR/xmlschema-1/#c-td> 1.2 does not, and vice versa. =
When
an xsi:type  <http://www.w3.org/TR/xml-infoset/#infoitem.element>
[attribute] is involved, however, clause
<http://www.w3.org/TR/xmlschema-1/#c-td> 1.2 takes precedence, as is =
made
clear in  <http://www.w3.org/TR/xmlschema-1/#cvc-elt> Element Locally =
Valid
(Element) (=A73.3.4)." This note isn't as helpful as one would like, =
however,
because  <http://www.w3.org/TR/xmlschema-1/#cvc-elt> Element Locally =
Valid
(Element) says that the element is invalid if the element declaration
specifies "abstract", regardless of xsi:type - in other words, the =
element
declaration, in this respect at least, actually takes precedence over
xsi:type!
 
It's all pretty murky. Saxon has decided the issue one way, which I =
think is
the common-sense way, but I think one could take a different =
interpretation.
 
Interesting question.
 
Michael Kay
http://www.saxonica.com/
 
 
  _____  

From: xmlschema-dev-request@w... [mailto:xmlschema-dev-request@w...] =
On
Behalf Of Stan Kitsis
Sent: 11 January 2006 00:21
To: xmlschema-dev@w...
Subject: abstract elements and xsi:type substitution



Is the following valid? Why or why not?

 

Thanks,

Stan Kitsis

 

******* XSD **************

 

<?xml version="1.0" encoding="utf-8" ?> 

<xs:schema targetNamespace="foo"

                  elementFormDefault="qualified"

                  xmlns="foo"

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

  

  <xs:element name="Item" type="xs:string" abstract="true"/>

</xs:schema>

 

******* XML **************

<?xml version="1.0" encoding="utf-8"?>

<Item xmlns="foo" 

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

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

          xsi:type="xs:string">text</Item>



transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent