Skip to content
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.
  • Loading branch information...
1 parent 7418fad commit 92b394fcf3991d63c2f46ba5c395db1f320cc7bd Kasimier T. Buchcik committed May 9, 2006
View
14 ChangeLog
@@ -1,3 +1,17 @@
+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>
* relaxng.c: Fixed compilation error with patch supplied by
View
1 result/schemas/subst-group-1_0_1
@@ -0,0 +1 @@
+./test/schemas/subst-group-1_1.xml validates
View
0 result/schemas/subst-group-1_0_1.err
No changes.
View
45 test/schemas/subst-group-1_0.xsd
@@ -0,0 +1,45 @@
+<?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>
View
12 test/schemas/subst-group-1_1.xml
@@ -0,0 +1,12 @@
+<?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>
+
View
18 xmlschemas.c
@@ -12551,9 +12551,21 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
*/
for (i = 0; i < substGroup->members->nbItems; i++) {
member = (xmlSchemaElementPtr) substGroup->members->items[i];
- tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
- member->name, member->targetNamespace,
- 1, 1, member);
+ /*
+ * NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2()
+ * 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);
}
} else {

0 comments on commit 92b394f

Please sign in to comment.
Something went wrong with that request. Please try again.