In looking for an answer some problems I've had importing and including schema in the same namespace I ran across these two messages and have not found any additional information. I think the issue I ran into and the ones in the below links are caused by the same code. Basically xmlschemas.c should allow imports/includes and redefinitions from the same schemaLocation. I've attached a test case and the proposed patch to fix.
http://mail.gnome.org/archives/xml/2007-January/msg00042.html http://mail.gnome.org/archives/xml/2007-January/msg00077.html Since the svn code is the same as shown in msg00077 and I have found no further discourse on the subject, I'm assuming this was never addressed, but it would be useful for more complex schemas.
test-cases.tar.bz2
Description: BZip2 compressed data
--- libxml2-svn-20090302.orig/xmlschemas.c 2009-03-02 19:29:01.000000000 -0500
+++ libxml2-svn-20090302/xmlschemas.c 2009-03-03 19:39:46.000000000 -0500
@@ -10343,27 +10343,39 @@
/* Did we already fetch the doc? */
if (bkt != NULL) {
- /* TODO: The following nasty cases will produce an error. */
if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) {
- /* We included/redefined and then try to import a schema. */
+ /*
+ * We included/redefined and then try to import a schema,
+ * but the new location provided for import was different.
+ */
if (schemaLocation == NULL)
schemaLocation = BAD_CAST "in_memory_buffer";
- xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
- invokingNode, NULL,
- "The schema document '%s' cannot be imported, since "
- "it was already included or redefined",
- schemaLocation, NULL);
- goto exit;
+ if (!xmlStrEqual(schemaLocation,
+ bkt->schemaLocation)) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
+ invokingNode, NULL,
+ "The schema document '%s' cannot be imported, since "
+ "it was already included or redefined",
+ schemaLocation, NULL);
+ goto exit;
+ }
} else if ((! WXS_IS_BUCKET_IMPMAIN(type)) && (bkt->imported)) {
- /* We imported and then try to include/redefine a schema. */
+ /*
+ * We imported and then try to include/redefine a schema,
+ * but the new location provided for the include/redefine
+ * was different.
+ */
if (schemaLocation == NULL)
schemaLocation = BAD_CAST "in_memory_buffer";
- xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
- invokingNode, NULL,
- "The schema document '%s' cannot be included or "
- "redefined, since it was already imported",
- schemaLocation, NULL);
- goto exit;
+ if (!xmlStrEqual(schemaLocation,
+ bkt->schemaLocation)) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
+ invokingNode, NULL,
+ "The schema document '%s' cannot be included or "
+ "redefined, since it was already imported",
+ schemaLocation, NULL);
+ goto exit;
+ }
}
}
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
