Commit 92b394fc authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik
Browse files

Fixed bug #341150, reported by Michael Romer. In

* xmlschemas.c: Fixed bug #341150, reported by Michael Romer.
  In xmlSchemaBuildContentModelForSubstGroup(),
  xmlAutomataNewOnceTrans2() was incorrectly used instead of
  xmlAutomataNewTransition2() to mimic a xs:choice for
  substitution-groups.
* test/schemas/subst-group-1_1.xsd
  test/schemas/subst-group-1_0.xml
  result/schemas/subst-group-1_0_1
  result/schemas/subst-group-1_0_1.err: Added regression test
  supplied by Michael Romer for bug #341150.
parent 7418fad2
Tue May 9 21:47:58 CEST 2006 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c: Fixed bug #341150, reported by Michael Romer.
In xmlSchemaBuildContentModelForSubstGroup(),
xmlAutomataNewOnceTrans2() was incorrectly used instead of
xmlAutomataNewTransition2() to mimic a xs:choice for
substitution-groups.
* test/schemas/subst-group-1_1.xsd
test/schemas/subst-group-1_0.xml
result/schemas/subst-group-1_0_1
result/schemas/subst-group-1_0_1.err: Added regression test
supplied by Michael Romer for bug #341150.
Sat May 6 11:05:24 HKT 2006 William M. Brack <wbrack@mmm.com.hk> Sat May 6 11:05:24 HKT 2006 William M. Brack <wbrack@mmm.com.hk>
* relaxng.c: Fixed compilation error with patch supplied by * relaxng.c: Fixed compilation error with patch supplied by
......
./test/schemas/subst-group-1_1.xml validates
<?xml version="1.0" encoding="UTF-8"?>
<!-- Test for bug #341150 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<!-- This is the head of our substitution group for events that have only
simple content. -->
<xs:element name="SimpleEvent" type="SimpleEventType"/>
<!-- All SimpleEvent elements have the required set of attributes -->
<xs:complexType name="SimpleEventType">
<xs:simpleContent>
<xs:extension base="xs:anySimpleType">
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Common members of the SimpleEvent substitution group -->
<xs:element name="TestEvent" substitutionGroup="SimpleEvent">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="SimpleEventType">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<!-- Root element -->
<xs:element name="TestRoot" type="TestRootType"/>
<!-- Core data type of an audit trail -->
<xs:complexType name="TestRootType">
<xs:sequence>
<xs:element name="Events">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="SimpleEvent"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- Test for bug #341150 -->
<TestRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="subst-group-1.xsd">
<Events>
<TestEvent>Test 1.</TestEvent>
<!-- Uncomment the following element to cause libxml's xmllint to
fail to validate. -->
<TestEvent>Test 2.</TestEvent>
</Events>
</TestRoot>
...@@ -12551,9 +12551,21 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt, ...@@ -12551,9 +12551,21 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
*/ */
for (i = 0; i < substGroup->members->nbItems; i++) { for (i = 0; i < substGroup->members->nbItems; i++) {
member = (xmlSchemaElementPtr) substGroup->members->items[i]; member = (xmlSchemaElementPtr) substGroup->members->items[i];
tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL, /*
member->name, member->targetNamespace, * NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2()
1, 1, member); * was incorrectly used instead of xmlAutomataNewTransition2()
* (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL
* section in xmlSchemaBuildAContentModel() ).
* TODO: Check if xmlAutomataNewOnceTrans2() was instead
* intended for the above "counter" section originally. I.e.,
* check xs:all with subst-groups.
*
* tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
* member->name, member->targetNamespace,
* 1, 1, member);
*/
tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL,
member->name, member->targetNamespace, member);
xmlAutomataNewEpsilon(pctxt->am, tmp, end); xmlAutomataNewEpsilon(pctxt->am, tmp, end);
} }
} else { } else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment