xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r804211 - in /xerces/c/trunk/tests/src/XSTSHarness: XSTSHarness.cpp XSTSHarness.hpp XSTSHarnessHandlers.cpp XSTSHarnessHandlers.hpp
Date Fri, 14 Aug 2009 13:18:10 GMT
Author: amassari
Date: Fri Aug 14 13:18:09 2009
New Revision: 804211

URL: http://svn.apache.org/viewvc?rev=804211&view=rev
Log:
Use an entity resolver to feed the grammar for the XML namespace

Modified:
    xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.cpp
    xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.hpp
    xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.cpp
    xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.hpp

Modified: xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.cpp?rev=804211&r1=804210&r2=804211&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.cpp (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.cpp Fri Aug 14 13:18:09 2009
@@ -37,6 +37,7 @@
 #include <fstream.h>
 #endif
 #include <xercesc/util/OutOfMemoryException.hpp>
+#include <xercesc/framework/MemBufInputSource.hpp>
 
 static XMLCh sz_XMLTestSuiteRoot[]={ chLatin_T, chLatin_E, chLatin_S, chLatin_T, chLatin_S,
chLatin_U, chLatin_I, chLatin_T, chLatin_E, chNull };
 const XMLCh dummy[]={ chLatin_f, chLatin_i, chLatin_l, chLatin_e, chColon, chForwardSlash,
chForwardSlash, 
@@ -150,6 +151,56 @@
 
 /////////////////////////////////////////////////////////////////////
 
+InputSource* BaseEntityResolver::resolveEntity(XMLResourceIdentifier* resourceIdentifier)
+{
+    if(XMLString::equals(resourceIdentifier->getNameSpace(), XMLUni::fgXMLURIName))
+    {
+        static const char* xmlXsd=  "<?xml version='1.0'?>"
+                                    "<xs:schema targetNamespace='http://www.w3.org/XML/1998/namespace'
"
+                                    "  xmlns:xs='http://www.w3.org/2001/XMLSchema' "
+                                    "  xml:lang='en'>"
+                                    ""
+                                    " <xs:attribute name='lang'>"
+                                    "  <xs:simpleType>"
+                                    "   <xs:union memberTypes='xs:language'>"
+                                    "    <xs:simpleType>"
+                                    "     <xs:restriction base='xs:string'>"
+                                    "      <xs:enumeration value=''/>"
+                                    "     </xs:restriction>"
+                                    "    </xs:simpleType>"
+                                    "   </xs:union>"
+                                    "  </xs:simpleType>"
+                                    " </xs:attribute>"
+                                    ""
+                                    " <xs:attribute name='space'>"
+                                    "  <xs:simpleType>"
+                                    "   <xs:restriction base='xs:NCName'>"
+                                    "    <xs:enumeration value='default'/>"
+                                    "    <xs:enumeration value='preserve'/>"
+                                    "   </xs:restriction>"
+                                    "  </xs:simpleType>"
+                                    " </xs:attribute>"
+                                    ""
+                                    " <xs:attribute name='base' type='xs:anyURI'>"
+                                    " </xs:attribute>"
+                                    ""
+                                    " <xs:attribute name='id' type='xs:ID'>"
+                                    " </xs:attribute>"
+                                    ""
+                                    " <xs:attributeGroup name='specialAttrs'>"
+                                    "  <xs:attribute ref='xml:base'/>"
+                                    "  <xs:attribute ref='xml:lang'/>"
+                                    "  <xs:attribute ref='xml:space'/>"
+                                    "  <xs:attribute ref='xml:id'/>"
+                                    " </xs:attributeGroup>"
+                                    ""
+                                    "</xs:schema>";
+        return new MemBufInputSource((XMLByte*)xmlXsd, strlen(xmlXsd), "");
+    }
+    return 0;
+}
+
+/////////////////////////////////////////////////////////////////////
 
 class RootExtractor : public DefaultHandler
 {

Modified: xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.hpp?rev=804211&r1=804210&r2=804211&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.hpp (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/XSTSHarness.hpp Fri Aug 14 13:18:09 2009
@@ -38,6 +38,7 @@
 #include <xercesc/sax2/SAX2XMLReader.hpp>
 #include <xercesc/sax2/DefaultHandler.hpp>
 #include <xercesc/util/XMLURL.hpp>
+#include <xercesc/util/XMLEntityResolver.hpp>
 
 XERCES_CPP_NAMESPACE_USE
 
@@ -170,4 +171,13 @@
     XMLBuffer       fErrorText;
 };
 
+class BaseEntityResolver : public XMLEntityResolver
+{
+public:
+    BaseEntityResolver() {};
+
+    virtual InputSource* resolveEntity(XMLResourceIdentifier* resourceIdentifier);
+
+};
+
 #endif

Modified: xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.cpp?rev=804211&r1=804210&r2=804211&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.cpp (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.cpp Fri Aug 14 13:18:09 2009
@@ -28,6 +28,7 @@
 #include <xercesc/sax/SAXException.hpp>
 #include <xercesc/validators/common/Grammar.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
+#include <xercesc/parsers/SAX2XMLReaderImpl.hpp>
 
 // ---------------------------------------------------------------------------
 //  XSTSHarnessHandlers: Constructors and Destructor
@@ -44,6 +45,7 @@
     fParser->setFeature(XMLUni::fgXercesUseCachedGrammarInParse, true);
     fParser->setFeature(XMLUni::fgXercesIdentityConstraintChecking, true);
     fParser->setErrorHandler(&fErrorHandler);
+    ((SAX2XMLReaderImpl*)fParser)->setXMLEntityResolver(&fEntityResolver);
 }
 
 XSTSHarnessHandlers::~XSTSHarnessHandlers()
@@ -328,4 +330,3 @@
         }
     }
 }
-

Modified: xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.hpp?rev=804211&r1=804210&r2=804211&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.hpp (original)
+++ xerces/c/trunk/tests/src/XSTSHarness/XSTSHarnessHandlers.hpp Fri Aug 14 13:18:09 2009
@@ -69,5 +69,6 @@
     XSTSTest            fCurrentTest;
     SAX2XMLReader*      fParser;
     BaseErrorHandler    fErrorHandler;
+    BaseEntityResolver  fEntityResolver;
 };
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org


Mime
View raw message