Author: amassari
Date: Thu Jul 17 02:54:34 2008
New Revision: 677550
URL: http://svn.apache.org/viewvc?rev=677550&view=rev
Log:
If an element cannot be found in the schema for its namespace, it is also
searched in the empty namespace to see if the user mistakenly forgot about
undefining the default namespace; in this case a better error report is
generated and (if schema processing is allowed to continue) the empty namespace
definition is taken. However, even if the empty namespace definition didn't
pass a few checks, we ended up silently using it -> we changed the namespace of
the element without notifying the user (XERCESC-1819)
Added:
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xml
xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xsd
Modified:
xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp?rev=677550&r1=677549&r2=677550&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp Thu Jul 17 02:54:34
2008
@@ -2322,33 +2322,37 @@
if (orgGrammarUri == uriId) {
// still not found in specified uri
- // try emptyNamesapce see if element should be
+ // try emptyNamespace see if element should be
// un-qualified.
+ // Use a temp variable until we decide this is the case
if (uriId != fEmptyNamespaceId) {
- elemDecl = fGrammar->getElemDecl(
+ XMLElementDecl* tempElemDecl =
fGrammar->getElemDecl(
fEmptyNamespaceId, nameRawBuf, qnameRawBuf,
currentScope
);
- if (elemDecl && elemDecl->getCreateReason() !=
XMLElementDecl::JustFaultIn && fValidate) {
+ if (tempElemDecl &&
tempElemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
fValidator->emitError(
- XMLValid::ElementNotUnQualified,
elemDecl->getFullName()
+ XMLValid::ElementNotUnQualified,
qnameRawBuf
);
+ elemDecl = tempElemDecl;
}
}
}
// still Not found in specified uri
// go to original Grammar again to see if element needs
// to be fully qualified.
+ // Use a temp variable until we decide this is the case
else if (uriId == fEmptyNamespaceId) {
if (switchGrammar(original_uriStr)) {
- elemDecl = fGrammar->getElemDecl(
+ XMLElementDecl* tempElemDecl =
fGrammar->getElemDecl(
orgGrammarUri, nameRawBuf, qnameRawBuf,
currentScope
);
- if (elemDecl && elemDecl->getCreateReason() !=
XMLElementDecl::JustFaultIn && fValidate) {
+ if (tempElemDecl &&
tempElemDecl->getCreateReason() != XMLElementDecl::JustFaultIn && fValidate) {
fValidator->emitError(
- XMLValid::ElementNotQualified,
elemDecl->getFullName()
+ XMLValid::ElementNotQualified, qnameRawBuf
);
+ elemDecl = tempElemDecl;
}
}
else if (!laxThisOne && fValidate) {
Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=677550&r1=677549&r2=677550&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Thu Jul 17 02:54:34
2008
@@ -1262,21 +1262,22 @@
}
if(!elemDecl) {
// still not found in specified uri
- // try emptyNamesapce see if element should be un-qualified.
- elemDecl = fGrammar->getElemDecl
+ // try emptyNamespace see if element should be un-qualified.
+ // Use a temp variable until we decide this is the case
+ XMLElementDecl* tempElemDecl = fGrammar->getElemDecl
(
fEmptyNamespaceId
, nameRawBuf
, qnameRawBuf
, currentScope
);
- bool errorCondition = elemDecl && elemDecl->getCreateReason()
!= XMLElementDecl::JustFaultIn;
- if (errorCondition && fValidate) {
+ if (tempElemDecl && tempElemDecl->getCreateReason() !=
XMLElementDecl::JustFaultIn && fValidate) {
fValidator->emitError
(
XMLValid::ElementNotUnQualified
- , elemDecl->getFullName()
+ , qnameRawBuf
);
+ elemDecl = tempElemDecl;
}
}
}
@@ -1375,19 +1376,21 @@
);
}
- elemDecl = fGrammar->getElemDecl
+ // Use a temp variable until we decide this is the case
+ XMLElementDecl* tempElemDecl = fGrammar->getElemDecl
(
orgGrammarUri
, nameRawBuf
, qnameRawBuf
, currentScope
);
- if (elemDecl && elemDecl->getCreateReason() !=
XMLElementDecl::JustFaultIn && fValidate) {
+ if (tempElemDecl && tempElemDecl->getCreateReason() !=
XMLElementDecl::JustFaultIn && fValidate) {
fValidator->emitError
(
XMLValid::ElementNotQualified
- , elemDecl->getFullName()
+ , qnameRawBuf
);
+ elemDecl=tempElemDecl;
}
}
}
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xml
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xml?rev=677550&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xml
(added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xml Thu
Jul 17 02:54:34 2008
@@ -0,0 +1,9 @@
+<t:root xmlns:t="test"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="test test.xsd">
+
+ <foo>foo</foo>
+ <t:bar>t:bar</t:bar>
+ <bar>bar</bar>
+
+</t:root>
Added: xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xsd
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xsd?rev=677550&view=auto
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xsd
(added)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/XERCESC-1819/test.xsd Thu
Jul 17 02:54:34 2008
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:t="test"
targetNamespace="test">
+
+ <complexType name="type">
+ <sequence>
+ <element name="foo" type="string"/>
+ <any namespace="##targetNamespace" processContents="skip"/>
+ <element name="bar" type="string"/>
+ </sequence>
+ </complexType>
+
+ <element name="root" type="t:type"/>
+
+</schema>
Modified: xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet
URL:
http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet?rev=677550&r1=677549&r2=677550&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/regression/Xerces.testSet Thu Jul 17
02:54:34 2008
@@ -520,4 +520,20 @@
<current status="accepted" date="2008-07-15"/>
</instanceTest>
</testGroup>
+ <testGroup name="XERCESC-1819">
+ <annotation>
+ <documentation>Failure to validate valid instance</documentation>
+ </annotation>
+ <documentationReference
xlink:href="https://issues.apache.org/jira/browse/XERCESC-1819"/>
+ <schemaTest name="XERCESC-1819-1">
+ <schemaDocument xlink:href="./XERCESC-1819/test.xsd"/>
+ <expected validity="valid"/>
+ <current status="accepted" date="2008-07-17"/>
+ </schemaTest>
+ <instanceTest name="XERCESC-1819-2">
+ <instanceDocument xlink:href="./XERCESC-1819/test.xml"/>
+ <expected validity="valid"/>
+ <current status="accepted" date="2008-07-17"/>
+ </instanceTest>
+ </testGroup>
</testSet>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]