You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2004/12/07 20:45:43 UTC
cvs commit: xml-xerces/c/src/xercesc/util XMLUni.cpp XMLUni.hpp
knoaman 2004/12/07 11:45:43
Modified: c/src/xercesc/internal DGXMLScanner.cpp IGXMLScanner.cpp
XMLScanner.cpp XMLScanner.hpp
c/src/xercesc/parsers DOMBuilderImpl.cpp
SAX2XMLReaderImpl.cpp SAXParser.cpp SAXParser.hpp
XercesDOMParser.cpp XercesDOMParser.hpp
c/src/xercesc/util XMLUni.cpp XMLUni.hpp
Log:
An option to ignore a cached DTD grammar when a document contains an
internal and external subset.
Revision Changes Path
1.58 +5 -2 xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp
Index: DGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/DGXMLScanner.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- DGXMLScanner.cpp 3 Dec 2004 19:40:30 -0000 1.57
+++ DGXMLScanner.cpp 7 Dec 2004 19:45:43 -0000 1.58
@@ -972,7 +972,10 @@
InputSource* srcUsed=0;
Janitor<InputSource> janSrc(srcUsed);
- if (fUseCachedGrammar)
+ // If we had an internal subset and we're using the cached grammar, it
+ // means that the ignoreCachedDTD is set, so we ignore the cached
+ // grammar
+ if (fUseCachedGrammar && !hasIntSubset)
{
srcUsed = resolveSystemId(sysId, pubId);
janSrc.reset(srcUsed);
1.81 +6 -3 xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp
Index: IGXMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/IGXMLScanner.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- IGXMLScanner.cpp 3 Dec 2004 19:40:30 -0000 1.80
+++ IGXMLScanner.cpp 7 Dec 2004 19:45:43 -0000 1.81
@@ -1266,7 +1266,7 @@
Janitor<DTDElementDecl> rootDeclJanitor(rootDecl);
rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
rootDecl->setExternalElemDeclaration(true);
- if(!fUseCachedGrammar)
+ if(!fUseCachedGrammar)
{
// this will break getRootElemId on DTDGrammar when
// cached grammars are in use, but
@@ -1423,7 +1423,10 @@
InputSource* srcUsed=0;
Janitor<InputSource> janSrc(srcUsed);
- if (fUseCachedGrammar)
+ // If we had an internal subset and we're using the cached grammar, it
+ // means that the ignoreCachedDTD is set, so we ignore the cached
+ // grammar
+ if (fUseCachedGrammar && !hasIntSubset)
{
srcUsed = resolveSystemId(sysId, pubId);
janSrc.reset(srcUsed);
1.76 +4 -2 xml-xerces/c/src/xercesc/internal/XMLScanner.cpp
Index: XMLScanner.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- XMLScanner.cpp 3 Dec 2004 19:40:30 -0000 1.75
+++ XMLScanner.cpp 7 Dec 2004 19:45:43 -0000 1.76
@@ -160,6 +160,7 @@
, fNormalizeData(true)
, fGenerateSyntheticAnnotations(false)
, fValidateAnnotations(false)
+ , fIgnoreCachedDTD(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
@@ -243,6 +244,7 @@
, fNormalizeData(true)
, fGenerateSyntheticAnnotations(false)
, fValidateAnnotations(false)
+ , fIgnoreCachedDTD(false)
, fErrorCount(0)
, fEntityExpansionLimit(0)
, fEntityExpansionCount(0)
@@ -1752,7 +1754,7 @@
if (fToCacheGrammar)
ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Val_CantHaveIntSS, fMemoryManager);
- if (fUseCachedGrammar && hasExtSubset )
+ if (fUseCachedGrammar && hasExtSubset && !fIgnoreCachedDTD)
{
InputSource* sysIdSrc = resolveSystemId(sysId, pubId);
Janitor<InputSource> janSysIdSrc(sysIdSrc);
1.45 +16 -0 xml-xerces/c/src/xercesc/internal/XMLScanner.hpp
Index: XMLScanner.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XMLScanner.hpp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- XMLScanner.hpp 3 Dec 2004 19:40:30 -0000 1.44
+++ XMLScanner.hpp 7 Dec 2004 19:45:43 -0000 1.45
@@ -16,6 +16,10 @@
/*
* $Log$
+ * Revision 1.45 2004/12/07 19:45:43 knoaman
+ * An option to ignore a cached DTD grammar when a document contains an
+ * internal and external subset.
+ *
* Revision 1.44 2004/12/03 19:40:30 cargilld
* Change call to resolveEntity to pass in public id so that only one call to resolveEntity is needed (a follow-on to Alberto's fix).
*
@@ -546,6 +550,7 @@
bool getGenerateSyntheticAnnotations() const;
bool getValidateAnnotations() const;
+ bool getIgnoreCachedDTD() const;
// -----------------------------------------------------------------------
// Getter methods
@@ -643,6 +648,7 @@
void setGenerateSyntheticAnnotations(const bool newValue);
void setValidateAnnotations(const bool newValue);
+ void setIgnoredCachedDTD(const bool newValue);
// -----------------------------------------------------------------------
// Mutator methods
@@ -1010,6 +1016,7 @@
bool fNormalizeData;
bool fGenerateSyntheticAnnotations;
bool fValidateAnnotations;
+ bool fIgnoreCachedDTD;
int fErrorCount;
unsigned int fEntityExpansionLimit;
unsigned int fEntityExpansionCount;
@@ -1366,6 +1373,11 @@
return fValidateAnnotations;
}
+inline bool XMLScanner::getIgnoreCachedDTD() const
+{
+ return fIgnoreCachedDTD;
+}
+
// ---------------------------------------------------------------------------
// XMLScanner: Setter methods
// ---------------------------------------------------------------------------
@@ -1533,6 +1545,11 @@
{
fBufferSize = bufferSize;
fCDataBuf.setFullHandler(this, fBufferSize);
+}
+
+inline void XMLScanner::setIgnoredCachedDTD(const bool newValue)
+{
+ fIgnoreCachedDTD = newValue;
}
// ---------------------------------------------------------------------------
1.42 +11 -3 xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp
Index: DOMBuilderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/DOMBuilderImpl.cpp,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- DOMBuilderImpl.cpp 28 Sep 2004 04:40:08 -0000 1.41
+++ DOMBuilderImpl.cpp 7 Dec 2004 19:45:43 -0000 1.42
@@ -243,7 +243,10 @@
{
getScanner()->setIdentityConstraintChecking(state);
}
-
+ else if (XMLString::compareIString(name, XMLUni::fgXercesIgnoreCachedDTD) == 0)
+ {
+ getScanner()->setIgnoredCachedDTD(state);
+ }
else {
throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());
}
@@ -342,6 +345,10 @@
{
return getScanner()->getValidateAnnotations();
}
+ else if (XMLString::compareIString(name, XMLUni::fgXercesIgnoreCachedDTD) == 0)
+ {
+ return getScanner()->getIgnoreCachedDTD();
+ }
else {
throw DOMException(DOMException::NOT_FOUND_ERR, 0, getMemoryManager());
}
@@ -365,7 +372,8 @@
(XMLString::compareIString(name, XMLUni::fgXercesDOMHasPSVIInfo) == 0) ||
(XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0) ||
(XMLString::compareIString(name, XMLUni::fgXercesGenerateSyntheticAnnotations) == 0) ||
- (XMLString::compareIString(name, XMLUni::fgXercesIdentityConstraintChecking) == 0)
+ (XMLString::compareIString(name, XMLUni::fgXercesIdentityConstraintChecking) == 0) ||
+ (XMLString::compareIString(name, XMLUni::fgXercesIgnoreCachedDTD) == 0)
) {
return true;
}
1.41 +9 -0 xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
Index: SAX2XMLReaderImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAX2XMLReaderImpl.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- SAX2XMLReaderImpl.cpp 4 Oct 2004 11:30:51 -0000 1.40
+++ SAX2XMLReaderImpl.cpp 7 Dec 2004 19:45:43 -0000 1.41
@@ -16,6 +16,10 @@
/*
* $Log$
+ * Revision 1.41 2004/12/07 19:45:43 knoaman
+ * An option to ignore a cached DTD grammar when a document contains an
+ * internal and external subset.
+ *
* Revision 1.40 2004/10/04 11:30:51 amassari
* As start/endPrefixMapping doesn't use the XMLBufMgr variable, we need only one XMLBuffer
*
@@ -1573,6 +1577,10 @@
{
fScanner->setValidateAnnotations(value);
}
+ else if (XMLString::compareIString(name, XMLUni::fgXercesIgnoreCachedDTD) == 0)
+ {
+ fScanner->setIgnoredCachedDTD(value);
+ }
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
}
@@ -1611,6 +1619,8 @@
return fScanner->getGenerateSyntheticAnnotations();
else if (XMLString::compareIString(name, XMLUni::fgXercesValidateAnnotations) == 0)
return fScanner->getValidateAnnotations();
+ else if (XMLString::compareIString(name, XMLUni::fgXercesIgnoreCachedDTD) == 0)
+ return fScanner->getIgnoreCachedDTD();
else
throw SAXNotRecognizedException("Unknown Feature", fMemoryManager);
1.37 +13 -0 xml-xerces/c/src/xercesc/parsers/SAXParser.cpp
Index: SAXParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- SAXParser.cpp 29 Sep 2004 19:00:29 -0000 1.36
+++ SAXParser.cpp 7 Dec 2004 19:45:43 -0000 1.37
@@ -16,6 +16,10 @@
/*
* $Log$
+ * Revision 1.37 2004/12/07 19:45:43 knoaman
+ * An option to ignore a cached DTD grammar when a document contains an
+ * internal and external subset.
+ *
* Revision 1.36 2004/09/29 19:00:29 peiyongz
* [jira1207] --patch from Dan Rosen
*
@@ -568,6 +572,11 @@
return fScanner->getSrcOffset();
}
+bool SAXParser::getIgnoreCachedDTD() const
+{
+ return fScanner->getIgnoreCachedDTD();
+}
+
// ---------------------------------------------------------------------------
// SAXParser: Setter methods
// ---------------------------------------------------------------------------
@@ -702,6 +711,11 @@
void SAXParser::setInputBufferSize(const size_t bufferSize)
{
fScanner->setInputBufferSize(bufferSize);
+}
+
+void SAXParser::setIgnoreCachedDTD(const bool newValue)
+{
+ fScanner->setIgnoredCachedDTD(newValue);
}
// ---------------------------------------------------------------------------
1.37 +29 -1 xml-xerces/c/src/xercesc/parsers/SAXParser.hpp
Index: SAXParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/SAXParser.hpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- SAXParser.hpp 29 Sep 2004 19:28:12 -0000 1.36
+++ SAXParser.hpp 7 Dec 2004 19:45:43 -0000 1.37
@@ -16,6 +16,10 @@
/*
* $Log$
+ * Revision 1.37 2004/12/07 19:45:43 knoaman
+ * An option to ignore a cached DTD grammar when a document contains an
+ * internal and external subset.
+ *
* Revision 1.36 2004/09/29 19:28:12 cargilld
* Mark SAXParser as deprecated.
*
@@ -680,6 +684,15 @@
*/
bool getValidateAnnotations() const;
+ /** Get the 'ignore cached DTD grammar' flag
+ *
+ * @return true, if the parser is currently configured to
+ * ignore cached DTD, false otherwise.
+ *
+ * @see #setIgnoreCachedDTD
+ */
+ bool getIgnoreCachedDTD() const;
+
//@}
@@ -948,7 +961,7 @@
* instead of building the grammar from scratch, to validate XML
* documents.
*
- * If the 'Grammar caching' flag is set to true, this mehod ignore the
+ * If the 'Grammar caching' flag is set to true, this method ignores the
* value passed in.
*
* The parser's default state is: false.
@@ -1007,6 +1020,22 @@
* @param bufferSize The maximum input buffer size
*/
void setInputBufferSize(const size_t bufferSize);
+
+ /** Set the 'ignore cached DTD grammar' flag
+ *
+ * This method gives users the option to ignore a cached DTD grammar, when
+ * an XML document contains both an internal and external DTD, and the use
+ * cached grammar from parse option is enabled. Currently, we do not allow
+ * using cached DTD grammar when an internal subset is present in the
+ * document. This option will only affect the behavior of the parser when
+ * an internal and external DTD both exist in a document (i.e. no effect
+ * if document has no internal subset).
+ *
+ * The parser's default state is false
+ *
+ * @param newValue The state to set
+ */
+ void setIgnoreCachedDTD(const bool newValue);
//@}
1.23 +10 -1 xml-xerces/c/src/xercesc/parsers/XercesDOMParser.cpp
Index: XercesDOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/XercesDOMParser.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XercesDOMParser.cpp 8 Sep 2004 13:56:18 -0000 1.22
+++ XercesDOMParser.cpp 7 Dec 2004 19:45:43 -0000 1.23
@@ -98,6 +98,11 @@
return getScanner()->getSrcOffset();
}
+bool XercesDOMParser::getIgnoreCachedDTD() const
+{
+ return getScanner()->getIgnoreCachedDTD();
+}
+
// ---------------------------------------------------------------------------
// XercesDOMParser: Setter methods
// ---------------------------------------------------------------------------
@@ -153,6 +158,10 @@
getScanner()->useCachedGrammarInParse(newState);
}
+void XercesDOMParser::setIgnoreCachedDTD(const bool newValue)
+{
+ getScanner()->setIgnoredCachedDTD(newValue);
+}
// ---------------------------------------------------------------------------
// XercesDOMParser: Utilities
1.21 +26 -1 xml-xerces/c/src/xercesc/parsers/XercesDOMParser.hpp
Index: XercesDOMParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/parsers/XercesDOMParser.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XercesDOMParser.hpp 8 Sep 2004 13:56:18 -0000 1.20
+++ XercesDOMParser.hpp 7 Dec 2004 19:45:43 -0000 1.21
@@ -200,6 +200,15 @@
*/
unsigned int getSrcOffset() const;
+ /** Get the 'ignore cached DTD grammar' flag
+ *
+ * @return true, if the parser is currently configured to
+ * ignore cached DTD, false otherwise.
+ *
+ * @see #setIgnoreCachedDTD
+ */
+ bool getIgnoreCachedDTD() const;
+
//@}
@@ -300,6 +309,22 @@
* @see #cacheGrammarFromParse
*/
void useCachedGrammarInParse(const bool newState);
+
+ /** Set the 'ignore cached DTD grammar' flag
+ *
+ * This method gives users the option to ignore a cached DTD grammar, when
+ * an XML document contains both an internal and external DTD, and the use
+ * cached grammar from parse option is enabled. Currently, we do not allow
+ * using cached DTD grammar when an internal subset is present in the
+ * document. This option will only affect the behavior of the parser when
+ * an internal and external DTD both exist in a document (i.e. no effect
+ * if document has no internal subset).
+ *
+ * The parser's default state is false
+ *
+ * @param newValue The state to set
+ */
+ void setIgnoreCachedDTD(const bool newValue);
//@}
1.46 +16 -1 xml-xerces/c/src/xercesc/util/XMLUni.cpp
Index: XMLUni.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- XMLUni.cpp 28 Sep 2004 02:14:14 -0000 1.45
+++ XMLUni.cpp 7 Dec 2004 19:45:43 -0000 1.46
@@ -1258,6 +1258,21 @@
, chLatin_s, chLatin_e, chNull
};
+//Xerces: http://apache.org/xml/features/validation/ignoreCachedDTD
+const XMLCh XMLUni::fgXercesIgnoreCachedDTD[] =
+{
+ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash
+ , chForwardSlash, chLatin_a, chLatin_p, chLatin_a, chLatin_c, chLatin_h
+ , chLatin_e, chPeriod, chLatin_o, chLatin_r, chLatin_g, chForwardSlash
+ , chLatin_x, chLatin_m, chLatin_l, chForwardSlash, chLatin_f, chLatin_e
+ , chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chLatin_s
+ , chForwardSlash, chLatin_v, chLatin_a, chLatin_l, chLatin_i, chLatin_d
+ , chLatin_a, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chForwardSlash
+ , chLatin_i, chLatin_g, chLatin_n, chLatin_o, chLatin_r, chLatin_e
+ , chLatin_C, chLatin_a, chLatin_c, chLatin_h, chLatin_e, chLatin_d
+ , chLatin_D, chLatin_T, chLatin_D, chNull
+};
+
//Introduced in DOM Level 3
const XMLCh XMLUni::fgDOMCanonicalForm[] =
1.41 +2 -1 xml-xerces/c/src/xercesc/util/XMLUni.hpp
Index: XMLUni.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLUni.hpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- XMLUni.hpp 28 Sep 2004 02:14:14 -0000 1.40
+++ XMLUni.hpp 7 Dec 2004 19:45:43 -0000 1.41
@@ -223,6 +223,7 @@
static const XMLCh fgXercesDOMHasPSVIInfo[];
static const XMLCh fgXercesGenerateSyntheticAnnotations[];
static const XMLCh fgXercesValidateAnnotations[];
+ static const XMLCh fgXercesIgnoreCachedDTD[];
// SAX2 features/properties names
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org