2007-08-22 14:38:20 +02:00
|
|
|
#ifndef ARABICA_XSLT_STYLESHEETPARSER_HPP
|
|
|
|
#define ARABICA_XSLT_STYLESHEETPARSER_HPP
|
|
|
|
|
|
|
|
#include <SAX/filter/NamespaceTracker.hpp>
|
|
|
|
#include <SAX/filter/XMLBaseTracker.hpp>
|
|
|
|
#include <SAX/filter/TextCoalescer.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace Arabica
|
|
|
|
{
|
|
|
|
namespace XSLT
|
|
|
|
{
|
|
|
|
|
2007-08-23 15:55:06 +02:00
|
|
|
class StylesheetParser
|
2007-08-22 14:38:20 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
StylesheetParser() { }
|
|
|
|
|
2007-09-05 14:57:07 +02:00
|
|
|
void setContentHandler(SAX::ContentHandler<std::string>& handler)
|
2007-08-22 14:38:20 +02:00
|
|
|
{
|
|
|
|
namespace_tracker_.setContentHandler(handler);
|
|
|
|
} // setContentHandler
|
2007-08-24 14:37:32 +02:00
|
|
|
|
2007-09-05 14:57:07 +02:00
|
|
|
SAX::ContentHandler<std::string>& contentHandler()
|
2007-08-24 14:37:32 +02:00
|
|
|
{
|
|
|
|
return text_coalescer_;
|
|
|
|
} // contentHandler
|
2007-08-22 14:38:20 +02:00
|
|
|
|
2007-09-05 14:57:07 +02:00
|
|
|
void parse(SAX::InputSource<std::string>& source)
|
2007-08-22 14:38:20 +02:00
|
|
|
{
|
|
|
|
SAX::XMLReader<std::string> base_parser;
|
|
|
|
text_coalescer_.setParent(base_parser);
|
|
|
|
xmlbase_tracker_.setParent(text_coalescer_);
|
|
|
|
namespace_tracker_.setParent(xmlbase_tracker_);
|
|
|
|
|
|
|
|
namespace_tracker_.parse(source);
|
|
|
|
} // parse
|
|
|
|
|
2007-08-23 15:55:06 +02:00
|
|
|
std::string namespaceURI(const std::string& prefix) const
|
2007-08-22 14:38:20 +02:00
|
|
|
{
|
|
|
|
return namespace_tracker_.getURI(prefix);
|
|
|
|
} // namespaceURI
|
|
|
|
|
|
|
|
std::pair<std::string, std::string> processQName(const std::string& qName) const
|
|
|
|
{
|
|
|
|
return namespace_tracker_.process(qName);
|
|
|
|
} // processQName
|
|
|
|
|
|
|
|
std::map<std::string, std::string> inScopeNamespaces() const
|
|
|
|
{
|
|
|
|
return namespace_tracker_.inScopeNamespaces();
|
|
|
|
} // inScopeNamespaces
|
|
|
|
|
2007-08-24 14:37:32 +02:00
|
|
|
std::string setBase(const std::string& loc)
|
|
|
|
{
|
|
|
|
std::string current = currentBase();
|
|
|
|
xmlbase_tracker_.setDocumentLocation(loc);
|
|
|
|
return current;
|
|
|
|
} // setBase
|
|
|
|
|
2007-08-23 15:55:06 +02:00
|
|
|
std::string currentBase() const
|
|
|
|
{
|
|
|
|
return xmlbase_tracker_.currentBase();
|
|
|
|
} // currentBase
|
|
|
|
|
2007-08-22 14:38:20 +02:00
|
|
|
std::string makeAbsolute(const std::string& href)
|
|
|
|
{
|
|
|
|
return xmlbase_tracker_.makeAbsolute(href);
|
|
|
|
} // makeAbsolute
|
|
|
|
|
|
|
|
private:
|
|
|
|
SAX::TextCoalescer<std::string> text_coalescer_;
|
|
|
|
SAX::XMLBaseTracker<std::string> xmlbase_tracker_;
|
|
|
|
SAX::NamespaceTracker<std::string> namespace_tracker_;
|
|
|
|
|
|
|
|
StylesheetParser(const StylesheetParser&);
|
|
|
|
StylesheetParser operator=(const StylesheetParser&);
|
|
|
|
bool operator==(const StylesheetParser&);
|
|
|
|
}; // class StylesheetParser
|
|
|
|
|
|
|
|
} // namespace XSLT
|
|
|
|
} // namespace Arabica
|
|
|
|
|
|
|
|
#endif // ARABICA_XSLT_STYLESHEETPARSER_HPP
|
|
|
|
|