[xml] [Patch] complex type extension cardinality mismatch




Hello,

It seems that there is an issue regarding the inheritance of cardinality in complex type extension.
I have attached a simple XML file with the corresponding XSD, where "ItemWithNumber" is
a complexType extending the base type "Item". "Item" contains a unbounded sequence of "Name"
elements, but libxml2/xmllint does not allow more than one "Name" in the elements
 of type "ItemWithNumber" present in the XML. I may be mistaken, but I think it is not the expected behavior.
By the way, it seems that someone has already opened a bug related to the same problem in bugzilla #609796
 (https://bugzilla.gnome.org/show_bug.cgi?id=609796) "Failure to validate optional element in complex type 
extension".

The following patch fixes the validation of both my test case and the one reported in bugzilla #609796.

Please let me know if you need more information regarding this issue.

Regards,

From bfc8fb6663d5d57a41cc6ea158141b4423b7653c Mon Sep 17 00:00:00 2001
From: Remi Gacogne <rgacogne denyall com>
Date: Fri, 12 Nov 2010 15:44:12 +0100
Subject: [PATCH] Fix complex type extension cardinality mismatch

---
 xmlschemas.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xmlschemas.c b/xmlschemas.c
index 5de7ca5..d565b9d 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -18474,9 +18474,9 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
                    */
                    particle->children->children =
                        (xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt,
-                       type->node,
-                       ((xmlSchemaParticlePtr) type->subtypes)->minOccurs,
-                       ((xmlSchemaParticlePtr) type->subtypes)->maxOccurs);
+                       baseType->node,
+                       ((xmlSchemaParticlePtr) baseType->subtypes)->minOccurs,
+                       ((xmlSchemaParticlePtr) baseType->subtypes)->maxOccurs);
                    if (particle->children->children == NULL)
                        goto exit_failure;
                    particle = (xmlSchemaParticlePtr)
--
1.5.6.5

-- 
Rémi Gacogne
R&D Core Engineer
rgacogne denyall com

Deny All - 23, rue Notre-Dame des Victoires 75002 Paris - France
www.denyall.com

Attachment: items.xml
Description: application/xml

Attachment: items.xsd
Description: application/xsd

Attachment: signature.asc
Description: This is a digitally signed message part.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]