diff --git a/result/schemas/issue40_0_0 b/result/schemas/issue40_0_0
new file mode 100644
index 00000000..73c9e696
--- /dev/null
+++ b/result/schemas/issue40_0_0
@@ -0,0 +1 @@
+./test/schemas/issue40_0.xml validates
diff --git a/result/schemas/issue40_0_0.err b/result/schemas/issue40_0_0.err
new file mode 100644
index 00000000..e69de29b
diff --git a/test/schemas/issue40_0.xml b/test/schemas/issue40_0.xml
new file mode 100644
index 00000000..86cff1d0
--- /dev/null
+++ b/test/schemas/issue40_0.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/test/schemas/issue40_0.xsd b/test/schemas/issue40_0.xsd
new file mode 100644
index 00000000..a7eff55b
--- /dev/null
+++ b/test/schemas/issue40_0.xsd
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/xmlregexp.c b/xmlregexp.c
index 1e8bf934..10969177 100644
--- a/xmlregexp.c
+++ b/xmlregexp.c
@@ -2528,9 +2528,18 @@ xmlFACompareAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2, int deep) {
case XML_REGEXP_STRING:
if (!deep)
ret = (atom1->valuep != atom2->valuep);
- else
- ret = xmlRegStrEqualWildcard((xmlChar *)atom1->valuep,
- (xmlChar *)atom2->valuep);
+ else {
+ xmlChar *val1 = (xmlChar *)atom1->valuep;
+ xmlChar *val2 = (xmlChar *)atom2->valuep;
+ int compound1 = (xmlStrchr(val1, '|') != NULL);
+ int compound2 = (xmlStrchr(val2, '|') != NULL);
+
+ /* Ignore negative match flag for ##other namespaces */
+ if (compound1 != compound2)
+ return(0);
+
+ ret = xmlRegStrEqualWildcard(val1, val2);
+ }
break;
case XML_REGEXP_EPSILON:
goto not_determinist;