[Greater-commits] r371 - trunk/Administration

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jul 7 15:37:37 CEST 2011


Author: bricks
Date: 2011-07-07 15:37:37 +0200 (Thu, 07 Jul 2011)
New Revision: 371

Added:
   trunk/Administration/DTDEntityResolver.cpp
   trunk/Administration/DTDEntityResolver.h
Log:
Add a XMLEntityResolver Class to load greater.dtd from the current
application working dir instead of the directory of the xml file


Added: trunk/Administration/DTDEntityResolver.cpp
===================================================================
--- trunk/Administration/DTDEntityResolver.cpp	2011-07-07 13:25:47 UTC (rev 370)
+++ trunk/Administration/DTDEntityResolver.cpp	2011-07-07 13:37:37 UTC (rev 371)
@@ -0,0 +1,40 @@
+/**************************************************************************
+* Copyright (C) 2011  Intevation GmbH, Osnabrueck, Germany
+*
+* Authors: Bjoern Ricks <bjoern.ricks at intevation.de>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*
+***************************************************************************/
+
+#include "DTDEntityResolver.h"
+
+#include <xercesc/framework/LocalFileInputSource.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <stdio.h>
+
+
+InputSource * DTDEntityResolver::resolveEntity(XMLResourceIdentifier* xmlri) {
+    switch(xmlri->getResourceIdentifierType()) {
+        case XMLResourceIdentifier::ExternalEntity:
+            if (XMLString::equals(xmlri->getSystemId(), XMLString::transcode("greater.dtd"))) {
+                return new LocalFileInputSource(XMLString::transcode("greater.dtd"));
+            }
+            break;
+        default:
+            return NULL;
+    }
+}
+

Added: trunk/Administration/DTDEntityResolver.h
===================================================================
--- trunk/Administration/DTDEntityResolver.h	2011-07-07 13:25:47 UTC (rev 370)
+++ trunk/Administration/DTDEntityResolver.h	2011-07-07 13:37:37 UTC (rev 371)
@@ -0,0 +1,37 @@
+/**************************************************************************
+* Copyright (C) 2011  Intevation GmbH, Osnabrueck, Germany
+*
+* Authors: Bjoern Ricks <bjoern.ricks at intevation.de>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*
+***************************************************************************/
+
+#ifndef __DTDENTITYRESOLVER_H__
+#define __DTDENTITYRESOLVER_H__
+
+#include <xercesc/util/XMLEntityResolver.hpp>
+#include <xercesc/util/XMLResourceIdentifier.hpp>
+#include <xercesc/sax/InputSource.hpp>
+
+
+XERCES_CPP_NAMESPACE_USE
+
+class DTDEntityResolver : public XMLEntityResolver {
+    public:
+        InputSource * resolveEntity(XMLResourceIdentifier* xmlri);
+};
+
+#endif



More information about the Greater-commits mailing list