ome-common  5.5.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ome::common::xml::EntityResolver Class Reference

Xerces entity resolver. More...

#include <ome/common/xml/EntityResolver.h>

+ Inheritance diagram for ome::common::xml::EntityResolver:
+ Collaboration diagram for ome::common::xml::EntityResolver:

Public Member Functions

 EntityResolver ()
 Constructor.
 
 ~EntityResolver ()
 Destructor.
 
xercesc::InputSource * resolveEntity (xercesc::XMLResourceIdentifier *resource)
 Resolve an entity. More...
 
void registerEntity (const std::string &id, const boost::filesystem::path &file)
 Register a file with the entity resolver. More...
 
void registerCatalog (const boost::filesystem::path &file)
 Register a catalog with the entity resolver. More...
 

Private Types

typedef std::map< std::string, boost::filesystem::path > entity_path_map_type
 Mapping from system ID to filesystem path.
 
typedef std::map< std::string, std::string > entity_data_map_type
 Mapping from system ID to XML data.
 

Private Member Functions

xercesc::InputSource * getSource (const std::string &resource)
 Get input source from file. More...
 

Private Attributes

ome::common::Logger logger
 Message logger.
 
entity_path_map_type entity_path_map
 Map of registered system IDs to filesystem paths.
 
entity_data_map_type entity_data_map
 Map of system IDs to cached XML data.
 

Detailed Description

Xerces entity resolver.

This resolver allows replacement of URLs with local files or in-memory copies of XML schemas. This permits efficient validation without network access for commonly-used schemas.

Member Function Documentation

◆ getSource()

xercesc::InputSource * ome::common::xml::EntityResolver::getSource ( const std::string &  resource)
private

Get input source from file.

Open and read the contents of the file, then return this as an InputSource. Use cached content if possible.

Parameters
resourcethe resource to resolve.
Returns
the input source for the file, or null on failure.

References entity_data_map, entity_path_map, and logger.

Referenced by resolveEntity().

+ Here is the caller graph for this function:

◆ registerCatalog()

void ome::common::xml::EntityResolver::registerCatalog ( const boost::filesystem::path &  file)

Register a catalog with the entity resolver.

Parameters
filethe filename of the catalog.

References ome::common::canonical(), ome::common::xml::dom::createDocument(), ome::common::xml::dom::Document::getDocumentElement(), logger, and registerEntity().

◆ registerEntity()

void ome::common::xml::EntityResolver::registerEntity ( const std::string &  id,
const boost::filesystem::path &  file 
)

Register a file with the entity resolver.

Parameters
idthe XML system ID of the entity.
filethe filename of the entity.

References ome::common::canonical(), and entity_path_map.

Referenced by registerCatalog().

+ Here is the caller graph for this function:

◆ resolveEntity()

xercesc::InputSource * ome::common::xml::EntityResolver::resolveEntity ( xercesc::XMLResourceIdentifier *  resource)

Resolve an entity.

Parameters
resourcethe resource to resolve.
Returns
an input source containing the cached content, or null if the resource was not cached.

References getSource().


The documentation for this class was generated from the following files: