You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by David Bertoni <db...@apache.org> on 2008/09/17 08:19:11 UTC
Fix for XERCESC-1827 committed
I committed the temporary fix for this issue. However, during testing,
I discovered another bug in the SAX2XMLReader implementation when
namespace processing is disabled.
With the following document:
<foo:bar xmlns:foo="http://www.foo.com">data</foo:bar>
running SAX2Print with the -n option results in the following:
<?xml version="1.0" encoding="LATIN1"?>
<bar xmlns:foo="http://www.foo.com">data</foo:bar>
The problem is that the startElement event reports the following:
uri = ""
localname = "bar"
qname = "bar"
This is clearly wrong, and is also not what the SAX documentation requires:
http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html#startElement(java.lang.String,%20java.lang.String,%20java.lang.String,%20org.xml.sax.Attributes)
"Any or all of these may be provided, depending on the values of the
http://xml.org/sax/features/namespaces and the
http://xml.org/sax/features/namespace-prefixes properties:
the Namespace URI and local name are required when the namespaces
property is true (the default), and are optional when the namespaces
property is false (if one is specified, both must be);
the qualified name is required when the namespace-prefixes property is
true, and is optional when the namespace-prefixes property is false (the
default)."
So the callback provides the local name, but not the uri, and the
incorrect qname. In addition, when namespace processing is disabled, we
should either report _both_ the uri and localname, or neither, not just
the localname.
The bug is in SAX2XMLReaderImpl::startElement() and I think the
following patch should fix the problem:
Index: src/xercesc/parsers/SAX2XMLReaderImpl.cpp
===================================================================
--- src/xercesc/parsers/SAX2XMLReaderImpl.cpp (revision 695989)
+++ src/xercesc/parsers/SAX2XMLReaderImpl.cpp (working copy)
@@ -698,11 +698,11 @@
{
const QName* qName=elemDecl.getElementName();
const XMLCh* baseName=qName->getLocalPart();
- XMLCh* elemQName = 0;
+ const XMLCh* elemQName = 0;
if(elemPrefix==0 || *elemPrefix==0)
- elemQName=(XMLCh*)baseName;
+ elemQName=baseName;
else if(XMLString::equals(elemPrefix, qName->getPrefix()))
- elemQName=(XMLCh*)qName->getRawName();
+ elemQName=qName->getRawName();
else
{
fTempQName->set(elemPrefix);
@@ -771,8 +771,8 @@
if(fDocHandler)
{
fDocHandler->startElement(XMLUni::fgZeroLenString,
- baseName,
- elemQName,
+ XMLUni::fgZeroLenString,
+ qName->getRawName(),
fAttrList);
}
}
@@ -807,8 +807,8 @@
if(fDocHandler)
{
fDocHandler->endElement(XMLUni::fgZeroLenString,
- baseName,
- elemQName);
+ XMLUni::fgZeroLenString,
+ qName->getRawName());
}
}
}
Thoughts?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org