Dare,
here are 2 examples of schema: first one is validated Ok, and second one
fails. I have to process original schema as in second one. I can't change it
and I did not create it. And creators insist that schema is Ok.
The difference is that second schema uses substitutionGroup. And .net
validator fails over it.
At the same time, second variant is validated Ok by
http://apps.gotdotnet.com/xmltools/xsdvalidator/.
variant which passes XmlSchema.Compile:
<schema targetNamespace="sch" xmlns:xs="sch"
xmlns="http://www.w3.org/2001/XMLSchema" >
<simpleType name="monetary">
<restriction base="decimal"/>
</simpleType>
<simpleType name="shares">
<restriction base="decimal">
<minInclusive value="0"/>
</restriction>
</simpleType>
<element name="item-abs" type="decimal" abstract="true" />
<element id="iascf-pfs_WorkProgress" name="WorkProgress"
type="xs:monetary" />
<element id="iascf-pfs_WarrantyProvisionNonCurrent"
name="WarrantyProvisionNonCurrent" type="xs:monetary" />
</schema>
Variant, which fails in XmlSchema.Compile and passes in xsdvalidator:
<schema targetNamespace="sch" xmlns:xs="sch"
xmlns="http://www.w3.org/2001/XMLSchema" >
<simpleType name="monetary">
<restriction base="decimal"/>
</simpleType>
<simpleType name="shares">
<restriction base="decimal">
<minInclusive value="0"/>
</restriction>
</simpleType>
<element name="item-abs" type="decimal" abstract="true" />
<element id="iascf-pfs_WorkProgress" name="WorkProgress"
type="xs:monetary" substitutionGroup="xs:item-abs"/>
<element id="iascf-pfs_WarrantyProvisionNonCurrent"
name="WarrantyProvisionNonCurrent" type="xs:monetary"
substitutionGroup="xs:item-abs" />
</schema>
When I check what w3.org says on subtitution groups - I don't see why second
schema should fail.
Can you explain (or point out where I can see explanation for this) why
second variant fails in XmlSchema.Compile?
To me it looks like bug in .Net. Or where?
Sorry, if my previous example was not completely Ok. I hope this one is more
clear
Btw, would you mind to explain a bit what you mean by "...because the schema
for
Schema isn't actually a valid schema according to the rules specified in
the W3C XML Schema recommendation."?
Rgds
Alex
"Dare Obasanjo [MSFT]" <da***@online.microsoft.com> wrote in message
news:3f********@news.microsoft.com... This schema is NOT valid. There are several things wrong with it such as
the fact that you reference complex types such as "xs:annotated" and
"xs:facet" which are not defined in an imported schema for the
"http://www.w3.org/2001/XMLSchema" namespace. However, even if you did do
this I would suggest not trying to define interactions between
user-defined types and types defined in the schema for Schema because the schema for
Schema isn't actually a valid schema according to the rules specified in
the W3C XML Schema recommendation.
--
This posting is provided "AS IS" with no warranties, and confers no
rights.
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:O5**************@tk2msftngp13.phx.gbl... Further to previous.
I took example of subsitutionGroup definition from 3.3.2 at
http://www.w3.org/TR/xmlschema-1/#cElement_Declarations.
Test file I use is:
<xs:schema targetNamespace="schema" xmlns:x="schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="facet">
<xs:complexContent>
<xs:extension base="xs:annotated">
<xs:attribute name="value" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="facet" type="xs:facet" abstract="true"/>
<xs:element name="encoding" substitutionGroup="xs:facet">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:facet">
<xs:sequence>
<xs:element ref="annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:encodings"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="period" substitutionGroup="xs:facet">
<xs:complexType>
<xs:complexContent>
<xs:restriction base="xs:facet">
<xs:sequence>
<xs:element ref="annotation" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="value" type="xs:duration"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="datatype">
<xs:sequence>
<xs:element ref="facet" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:NCName" use="optional"/>
</xs:complexType>
</xs:schema>
.Net ReadXMLSchema or XmlSchema.Compile fails with:
System.Xml.Schema.XmlSchemaException: Reference to undeclared
substitution group
affiliation. An error occurred at , (13, 3).
Schema compile error:
System.Exception: Schema error --->
System.Xml.Schema.XmlSchemaException: Refere
nce to undeclared substitution group affiliation. An error occurred at ,
(13, 3)
.
--- End of inner exception stack trace ---
at XBRLMainClass.SchemaErrorHandler(Object sender,
ValidationEventArgs vea) i
n c:\...\Main.cs:line 88
at System.Xml.Schema.Compiler.SendValidationEvent(Xml SchemaException
e, XmlSe
verityType severity)
at
System.Xml.Schema.Compiler.CompileSubstitutionGrou p(XmlSchemaSubstitutionG roup substitutionGroup)
at System.Xml.Schema.Compiler.CompileTo(SchemaInfo schemaInfo)
at System.Xml.Schema.XmlSchema.Compile(XmlSchemaColle ction
collection, XmlNam
eTable nameTable, SchemaNames schemaNames, ValidationEventHandler
validationEven
tHandler, String targetNamespace, SchemaInfo schemaInfo, Boolean
compileContentM
odel, XmlResolver resolver)
at System.Xml.Schema.XmlSchema.Compile(ValidationEven tHandler
validationEvent
Handler).
And validator at
http://apps.gotdotnet.com/xmltools/x...r/Default.aspx fails in
different way:
Reference to undeclared substitution group affiliation. An error
occurred at , (13, 3).
Undefined complexType 'http://www.w3.org/2001/XMLSchema:annotated' is
used as a base for complex type extension". An error occurred at , (5, 5).
Type 'http://www.w3.org/2001/XMLSchema:facet' is not declared. An error
occurred at , (11, 3).
Undefined complexType 'http://www.w3.org/2001/XMLSchema:facet' is used
as a base for complex type restriction". An error occurred at , (16, 6).
Undefined complexType 'http://www.w3.org/2001/XMLSchema:facet' is used
as a base for complex type restriction". An error occurred at , (29, 6).
The 'facet' element is not declared. An error occurred at , (41, 5).
What's the problem?
Is the sample in w3.org docs wrong? Who is right, .Net validator,
gotdotnet validator or w3.org?
Can anybody point in right direction? Or provide a sample of xsd file
with substitution groups working with .Net validation?
PLEASE!!!!