Esempio n. 1
0
  void load_document(const std::string& location,
                     Arabica::XPath::NodeSet<std::string>& nodes) const
  {
    SAX2DOM::Parser<std::string> domParser;
    SAX::CatchErrorHandler<std::string> eh;
    domParser.setErrorHandler(eh);

    Arabica::io::URI base(baseURI_);
    Arabica::io::URI absolute(base, location);

    SAX::InputSource<std::string> is(absolute.as_string());
    domParser.parse(is);

    if(!eh.errorsReported())
        nodes.push_back(domParser.getDocument());
    else
        std::cerr << eh.errors() << std::endl;
  } // load_document
  void include_stylesheet(const string_type& href, const Precedence& precedence)
  {
    check_for_loops(href);
    current_includes_.push_back(href);

    string_type prev = context_->setBase(href);
    context_->set_precedence(precedence);

    SAX::InputSource<string_type, string_adaptor> source(href);
    SAX::XMLReader<string_type, string_adaptor> include_parser;
    SAX::CatchErrorHandler<string_type, string_adaptor> errorHandler;
 
    include_parser.setContentHandler(*this);
    include_parser.setErrorHandler(errorHandler);
    
    include_parser.parse(source);

    context_->setBase(prev);

    if(errorHandler.errorsReported())
      throw std::runtime_error("Could not import/include stylesheet '" + string_adaptor::asStdString(href) + "' - " + errorHandler.errors());

    current_includes_.pop_back();
  } // include_stylesheet