/*
- * Copyright 2001-2006 Internet2
+ * Copyright 2001-2007 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "internal.h"
#include "exceptions.h"
+#include "logging.h"
#include "util/NDC.h"
#include "util/ParserPool.h"
#include "util/XMLHelper.h"
#include <functional>
#include <sys/types.h>
#include <sys/stat.h>
-#include <log4cpp/Category.hh>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/XMLUniDefs.hpp>
#include <xercesc/sax/SAXException.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
#include <xercesc/framework/Wrapper4InputSource.hpp>
+using namespace xmltooling::logging;
using namespace xmltooling;
using namespace std;
-using namespace log4cpp;
ParserPool::ParserPool(bool namespaceAware, bool schemaAware)
: m_namespaceAware(namespaceAware), m_schemaAware(schemaAware), m_lock(Mutex::create()) {}
{
public:
doubleit(T& t, const typename T::value_type& s) : temp(t), sep(s) {}
- void operator() (const pair<T,T>& s) { temp += s.first + sep + s.first + sep; }
+ void operator() (const pair<const T,T>& s) { temp += s.first + sep + s.first + sep; }
T& temp;
const typename T::value_type& sep;
};
Category& log=Category::getInstance(XMLTOOLING_LOGCAT".ParserPool");
// XML constants
- static const XMLCh catalog[] = { chLatin_c, chLatin_a, chLatin_t, chLatin_a, chLatin_l, chLatin_o, chLatin_g, chNull };
- static const XMLCh uri[] = { chLatin_u, chLatin_r, chLatin_i, chNull };
- static const XMLCh name[] = { chLatin_n, chLatin_a, chLatin_m, chLatin_e, chNull };
+ static const XMLCh catalog[] = UNICODE_LITERAL_7(c,a,t,a,l,o,g);
+ static const XMLCh system[] = UNICODE_LITERAL_6(s,y,s,t,e,m);
+ static const XMLCh systemId[] = UNICODE_LITERAL_8(s,y,s,t,e,m,I,d);
+ static const XMLCh uri[] = UNICODE_LITERAL_3(u,r,i);
static const XMLCh CATALOG_NS[] = {
chLatin_u, chLatin_r, chLatin_n, chColon,
chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon,
return false;
}
- // Fetch all the <uri> elements.
- DOMNodeList* mappings=root->getElementsByTagNameNS(CATALOG_NS,uri);
+ // Fetch all the <system> elements.
+ DOMNodeList* mappings=root->getElementsByTagNameNS(CATALOG_NS,system);
Lock lock(m_lock);
for (XMLSize_t i=0; i<mappings->getLength(); i++) {
root=static_cast<DOMElement*>(mappings->item(i));
- const XMLCh* from=root->getAttributeNS(NULL,name);
+ const XMLCh* from=root->getAttributeNS(NULL,systemId);
const XMLCh* to=root->getAttributeNS(NULL,uri);
#ifdef HAVE_GOOD_STL
m_schemaLocMap[from]=to;
for_each(m_schemaLocMap.begin(),m_schemaLocMap.end(),doubleit<string>(m_schemaLocations,' '));
#endif
}
- catch (XMLParserException& e) {
- log.error("catalog loader caught XMLParserException: %s", e.what());
+ catch (exception& e) {
+ log.error("catalog loader caught exception: %s", e.what());
return false;
}
if (i!=m_schemaLocMap.end())
return new Wrapper4InputSource(new LocalFileInputSource(baseURI,i->second.c_str()));
- // We'll allow anything without embedded slashes.
- if (XMLString::indexOf(systemId, chForwardSlash)==-1)
- return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
-
// Check for entity as a value in the map.
for (i=m_schemaLocMap.begin(); i!=m_schemaLocMap.end(); ++i) {
if (XMLString::endsWith(i->second.c_str(), systemId))
return new Wrapper4InputSource(new LocalFileInputSource(baseURI,i->second.c_str()));
}
+
+ // We'll allow anything without embedded slashes.
+ if (XMLString::indexOf(systemId, chForwardSlash)==-1)
+ return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
#else
// Find well-known schemas in the specified location.
auto_ptr_char temp(systemId);
return new Wrapper4InputSource(new LocalFileInputSource(baseURI,temp2.get()));
}
- // We'll allow anything without embedded slashes.
- if (XMLString::indexOf(systemId, chForwardSlash)==-1)
- return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
-
// Check for entity as a value in the map.
for (i=m_schemaLocMap.begin(); i!=m_schemaLocMap.end(); ++i) {
- if (XMLString::endsWith(i->second.c_str(), temp.get())) {
- auto_ptr_XMLCh temp2(i->second.c_str());
+ auto_ptr_XMLCh temp2(i->second.c_str());
+ if (XMLString::endsWith(temp2.get(), systemId))
return new Wrapper4InputSource(new LocalFileInputSource(baseURI,temp2.get()));
- }
}
+
+ // We'll allow anything without embedded slashes.
+ if (XMLString::indexOf(systemId, chForwardSlash)==-1)
+ return new Wrapper4InputSource(new LocalFileInputSource(baseURI,systemId));
#endif
// Shortcircuit the request.
#ifdef HAVE_GOOD_STL
auto_ptr_char temp(systemId);
#endif
- log.warn("unauthorized entity request (%s), blocking it", temp.get());
+ log.debug("unauthorized entity request (%s), blocking it", temp.get());
static const XMLByte nullbuf[] = {0};
return new Wrapper4InputSource(new MemBufInputSource(nullbuf,0,systemId));
}