Package org.apache.xerces.parsers

Examples of org.apache.xerces.parsers.SAXParser


    }

  }

  void loadXMLModel(Model m2, InputStream in, RDFEHArray eh2) throws SAXException, IOException {
    XMLReader saxParser = new SAXParser();
    SAX2Model handler = SAX2Model.create(base, m2);
    SAX2RDF.installHandlers(saxParser, handler);
    handler.setErrorHandler(eh2);

    InputSource ins = new InputSource(in);
    ins.setSystemId(base);
    try {
      try {
        saxParser.parse(ins);
      } finally {
        handler.close();
      }
    } catch (SAXParseException e) {
      // already reported, leave it be.
View Full Code Here


      }

      RDFEHArray eh2 = new RDFEHArray();

      try ( InputStream in = new FileInputStream("testing/wg/rdfms-xmllang/test003.rdf") ) {
          XMLReader saxParser = new SAXParser();
          SAX2Model handler = SAX2Model.create("http://example.org/", m2,
              "fr");
          SAX2RDF.installHandlers(saxParser, handler);
          handler.setErrorHandler(eh2);

          InputSource ins = new InputSource(in);
          ins.setSystemId("http://example.org/");
          try {
              try {
                  saxParser.parse(ins);
              } finally {
                  handler.close();
              }
          } catch (SAXParseException e) {
              // already reported, leave it be.
View Full Code Here

    public void parse( final InputSource in,
                       final ContentHandler contentHandler,
                       final LexicalHandler lexicalHandler )
        throws SAXException, IOException
    {
        final SAXParser parser = createSAXParser();

        if( null != lexicalHandler )
        {
            parser.setProperty( "http://xml.org/sax/properties/lexical-handler",
                                lexicalHandler );
        }
        parser.setErrorHandler( this );
        parser.setContentHandler( contentHandler );
        parser.parse( in );
    }
View Full Code Here

     * @throws SAXException if unable to create parser
     */
    private SAXParser createSAXParser()
        throws SAXException
    {
        final SAXParser parser = new SAXParser();
        parser.setFeature( "http://xml.org/sax/features/validation", false );
        parser.setFeature( "http://xml.org/sax/features/namespaces", true );
        parser.setFeature( "http://xml.org/sax/features/namespace-prefixes",
                           true );
        return parser;
    }
View Full Code Here

     * Create a new <code>SAXParserFactoryImpl</code> instance.
     */
    protected SAXParserImpl(boolean namespaces, boolean validation)
    throws ParserConfigurationException {
        this();
        SAXParser p=new SAXParser();
        try {
            p.setFeature("http://xml.org/sax/features/namespaces",namespaces);
        } catch (SAXException e) {
            throw new ParserConfigurationException("Cannot set namespace "+
                "awareness to "+namespaces);
        }
        try {
            p.setFeature("http://xml.org/sax/features/validation",validation);
        } catch (SAXException e) {
            throw new ParserConfigurationException("Cannot set validation to "+
                validation);
        }
        this.namespaces=namespaces;
View Full Code Here

                xmlFormatter.format (document, tempWriter, NO_PARAMETERS);
                String tempXml = tempWriter.toString ();

                // For now, we just use Xerces - it would be more complicated to support
                // other parsers here.
                SAXParser parser = new SAXParser ();
                parser.setFeature("http://xml.org/sax/features/namespaces", true);
                driver.buildFOTree(parser, new InputSource (new StringReader (tempXml)));
            }
            else {
          driver.buildFOTree(document);
            }
View Full Code Here

  /**
   * @return a Xerces-specific <code>XMLReader</code> instance.
   */
  public static XMLReader getXMLReader() {
    return new SAXParser();
  }
View Full Code Here

    /** the Entity Resolver */
    protected Resolver resolver = null;

    public XercesParser ()
    throws SAXException {
        this.parser = new SAXParser();

        this.parser.setFeature("http://xml.org/sax/features/validation", false);
        this.parser.setFeature("http://xml.org/sax/features/namespaces", true);
    }
View Full Code Here

    }

  }

  void loadXMLModel(Model m2, InputStream in, RDFEHArray eh2) throws SAXException, IOException {
    XMLReader saxParser = new SAXParser();
    SAX2Model handler = SAX2Model.create(base, m2);
    SAX2RDF.installHandlers(saxParser, handler);
    handler.setErrorHandler(eh2);

    InputSource ins = new InputSource(in);
    ins.setSystemId(base);
    try {
      try {
        saxParser.parse(ins);
      } finally {
        handler.close();
      }
    } catch (SAXParseException e) {
      // already reported, leave it be.
View Full Code Here

    in.close();
    in = new FileInputStream("testing/wg/rdfms-xmllang/test003.rdf");

    RDFEHArray eh2 = new RDFEHArray();

    XMLReader saxParser = new SAXParser();
    SAX2Model handler = SAX2Model.create("http://example.org/", m2,
        "fr");
    SAX2RDF.installHandlers(saxParser, handler);
    handler.setErrorHandler(eh2);

    InputSource ins = new InputSource(in);
    ins.setSystemId("http://example.org/");
    try {
      try {
        saxParser.parse(ins);
      } finally {
        handler.close();
      }
    } catch (SAXParseException e) {
      // already reported, leave it be.
View Full Code Here

TOP

Related Classes of org.apache.xerces.parsers.SAXParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.