mirror of
https://gitlab.gnome.org/GNOME/libxml2
synced 2025-03-28 21:33:13 +00:00
XSD: optional element in complex type extension
For https://bugzilla.gnome.org/show_bug.cgi?id=609796 Libxml2 fails to validate an instance document against a schema if an element whose type is a complex extension of some base type with an optional child element and that child element is not specified in the instance document. For example, suppose I have some complex type BaseType that is defined to have one child element in a sequence group that has minOccurs set to 0
This commit is contained in:
parent
39d027cdb7
commit
4609e6c980
1
result/schemas/complex-type-extension_0_0
Normal file
1
result/schemas/complex-type-extension_0_0
Normal file
@ -0,0 +1 @@
|
||||
./test/schemas/complex-type-extension_0.xml validates
|
0
result/schemas/complex-type-extension_0_0.err
Normal file
0
result/schemas/complex-type-extension_0_0.err
Normal file
12
test/schemas/complex-type-extension_0.xml
Normal file
12
test/schemas/complex-type-extension_0.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ItemsList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Item xsi:type="ItemWithNumber">
|
||||
<Name>Name1</Name>
|
||||
<Number>20</Number>
|
||||
</Item>
|
||||
<Item xsi:type="ItemWithNumber">
|
||||
<Name>Name1</Name>
|
||||
<Name>Name2</Name>
|
||||
<Number>20</Number>
|
||||
</Item>
|
||||
</ItemsList>
|
27
test/schemas/complex-type-extension_0.xsd
Normal file
27
test/schemas/complex-type-extension_0.xsd
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
|
||||
<xs:complexType name="Item" abstract="true">
|
||||
<xs:sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<xs:element name="Name" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:complexType name="ItemWithNumber">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="Item">
|
||||
<xs:sequence>
|
||||
<xs:element name="Number" type="xs:nonNegativeInteger"/>
|
||||
</xs:sequence>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:element name="ItemsList">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Item" type="Item" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
@ -18476,8 +18476,8 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
|
||||
particle->children->children =
|
||||
(xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt,
|
||||
type->node,
|
||||
((xmlSchemaParticlePtr) type->subtypes)->minOccurs,
|
||||
((xmlSchemaParticlePtr) type->subtypes)->maxOccurs);
|
||||
((xmlSchemaParticlePtr) baseType->subtypes)->minOccurs,
|
||||
((xmlSchemaParticlePtr) baseType->subtypes)->maxOccurs);
|
||||
if (particle->children->children == NULL)
|
||||
goto exit_failure;
|
||||
particle = (xmlSchemaParticlePtr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user