cargilld 2005/04/05 08:16:36 Modified: c/samples/Redirect Redirect.cpp RedirectHandlers.cpp RedirectHandlers.hpp Log: Update Redirect sample to use newer entity resolver callback. Revision Changes Path 1.12 +6 -1 xml-xerces/c/samples/Redirect/Redirect.cpp Index: Redirect.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/samples/Redirect/Redirect.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- Redirect.cpp 8 Sep 2004 13:55:33 -0000 1.11 +++ Redirect.cpp 5 Apr 2005 15:16:36 -0000 1.12 @@ -35,6 +35,9 @@ * to read the contents of 'personal.dtd'. * * $Log$ + * Revision 1.12 2005/04/05 15:16:36 cargilld + * Update Redirect sample to use newer entity resolver callback. + * * Revision 1.11 2004/09/08 13:55:33 peiyongz * Apache License Version 2.0 * @@ -139,7 +142,9 @@ RedirectHandlers handler; parser->setDocumentHandler(&handler); parser->setErrorHandler(&handler); - parser->setEntityResolver(&handler); + //Use the new XML Entity Resolver + //parser->setEntityResolver(&handler); + parser->setXMLEntityResolver(&handler); // // Get the starting time and kick off the parse of the indicated file. 1.12 +38 -1 xml-xerces/c/samples/Redirect/RedirectHandlers.cpp Index: RedirectHandlers.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/samples/Redirect/RedirectHandlers.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- RedirectHandlers.cpp 12 Jan 2005 20:43:21 -0000 1.11 +++ RedirectHandlers.cpp 5 Apr 2005 15:16:36 -0000 1.12 @@ -133,6 +133,8 @@ } +#if 0 +// This is the old resolveEntity interface... // ----------------------------------------------------------------------- // Handlers for the SAX EntityResolver interface // ----------------------------------------------------------------------- @@ -167,3 +169,38 @@ // They were equal, so redirect to our other file return new LocalFileInputSource(gRedirectToFile); } +#endif +// ----------------------------------------------------------------------- +// Handlers for the XMLEntityResolver interface +// ----------------------------------------------------------------------- + +InputSource* RedirectHandlers::resolveEntity(XMLResourceIdentifier* resourceIdentifier) +{ + // + // If its our file, then create a new URL input source for the file that + // we want to really be used. Otherwise, just return zero to let the + // default action occur. + // + // We cannot assume that the XMLCh type is ok to pass to wcscmp(), so + // just do a comparison ourselves. + // + const XMLCh* s1 = gFileToTrap; + const XMLCh* s2 = resourceIdentifier->getSystemId(); + while (true) + { + // Break out on any difference + if (*s1 != *s2) + return 0; + + // If one is null, then both were null, so they are equal + if (!*s1) + break; + + // Else get the next char + s1++; + s2++; + } + + // They were equal, so redirect to our other file + return new LocalFileInputSource(gRedirectToFile); +} 1.9 +15 -2 xml-xerces/c/samples/Redirect/RedirectHandlers.hpp Index: RedirectHandlers.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/samples/Redirect/RedirectHandlers.hpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- RedirectHandlers.hpp 8 Sep 2004 13:55:33 -0000 1.8 +++ RedirectHandlers.hpp 5 Apr 2005 15:16:36 -0000 1.9 @@ -16,6 +16,9 @@ /* * $Log$ + * Revision 1.9 2005/04/05 15:16:36 cargilld + * Update Redirect sample to use newer entity resolver callback. + * * Revision 1.8 2004/09/08 13:55:33 peiyongz * Apache License Version 2.0 * @@ -52,6 +55,7 @@ // Includes // --------------------------------------------------------------------------- #include <xercesc/sax/HandlerBase.hpp> +#include <xercesc/util/XMLEntityResolver.hpp> XERCES_CPP_NAMESPACE_USE @@ -60,7 +64,7 @@ XERCES_CPP_NAMESPACE_END -class RedirectHandlers : public HandlerBase +class RedirectHandlers : public HandlerBase, public XMLEntityResolver { public: // ----------------------------------------------------------------------- @@ -111,6 +115,8 @@ void fatalError(const SAXParseException& exc); +#if 0 + // This is the old resolveEntity interface // ----------------------------------------------------------------------- // Handlers for the SAX EntityResolver interface // ----------------------------------------------------------------------- @@ -119,7 +125,14 @@ const XMLCh* const publicId , const XMLCh* const systemId ); - +#endif + // ----------------------------------------------------------------------- + // Handlers for the XMLEntityResolver interface + // ----------------------------------------------------------------------- + InputSource* resolveEntity + ( + XMLResourceIdentifier* resourceIdentifier + ); private: // -----------------------------------------------------------------------
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]