Package javax.xml.parsers

Examples of javax.xml.parsers.SAXParserFactory


  }

  public List<DefaultCreature> load(final URI ref) throws SAXException {
    list = new LinkedList<DefaultCreature>();
    // Use the default (non-validating) parser
    final SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
      // Parse the input
      final SAXParser saxParser = factory.newSAXParser();

      InputStream is = CreaturesXMLLoader.class.getResourceAsStream(ref.getPath());

      if (is == null) {
        throw new FileNotFoundException("cannot find resource '" + ref
View Full Code Here


  private String nature;

  public Collection<DefaultSpell> load(URI uri) throws SAXException {
    loadedSpells = new LinkedList<DefaultSpell>();
    // Use the default (non-validating) parser
    final SAXParserFactory factory = SAXParserFactory.newInstance();
    try {
      // Parse the input
      final SAXParser saxParser = factory.newSAXParser();

      final InputStream is = SpellXMLLoader.class.getResourceAsStream(uri.getPath());

      if (is == null) {
        throw new FileNotFoundException("cannot find resource '" + uri
View Full Code Here

        // look it up using the Wikipedia API
        final HttpClient httpClient = new HttpClient(
            "http://en.wikipedia.org/w/api.php?action=query&titles="
                + keyword.replace(' ', '_').replace("%", "%25")
                + "&prop=revisions&rvprop=content&format=xml");
        final SAXParserFactory factory = SAXParserFactory.newInstance();

        // Parse the input
        final SAXParser saxParser = factory.newSAXParser();
        saxParser.parse(httpClient.getInputStream(), this);

        final String response = getText();

        if (response.startsWith("#REDIRECT")) {
View Full Code Here

        }

        SAXParser parser;

        // Use the default (non-validating) parser
        final SAXParserFactory factory = SAXParserFactory.newInstance();
        try {
          parser = factory.newSAXParser();
          parser.parse(in, this);
        } catch (final Exception e) {
          logger.error(e);
        } finally {
          try {
View Full Code Here

      this.elementsWithNoHandlers.add(name);
   }

   public void parse(InputStream io) throws ParserException {
      try {
         SAXParserFactory factory = SAXParserFactory.newInstance();
         factory.setValidating(true);
         factory.setNamespaceAware(true);
         SAXParser parser = factory.newSAXParser();
         XMLReader reader = parser.getXMLReader();

         reader.setContentHandler(this);
         reader.setErrorHandler(new Frame2ParseErrorHandler());
         reader.setEntityResolver(new Frame2EntityResolver());
View Full Code Here

   * @param context The context instance to use with the handler
   * @return The handler for chaining
   */
  public static <CTX extends XMLContext, D extends IXMLDocument<CTX>> CTX parse (IInputSource input, D handler, CTX context) {
    try {
      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser parser = factory.newSAXParser();
     
      XMLReader<CTX> xmlHandler = new XMLReader<CTX>(handler, context);
     
      org.xml.sax.XMLReader reader = parser.getXMLReader();
      reader.setContentHandler(xmlHandler);
View Full Code Here

      SAXException,
      IOException,
      ParserConfigurationException {

    // Create a JAXP SAXParserFactory
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setNamespaceAware(true);
    spf.setValidating(true);

    // Create a JAXP SAXParser
    SAXParser saxParser = spf.newSAXParser();

    // Set the schema language
    saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);

    // Set the schema source.
View Full Code Here

   * @param document A previously created XML document that will used to fill in the class
   * @return The same instance that was used by the document
   */
  public static Object read (InputStream in, XMLDocument document) {
    try {
      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser parser = factory.newSAXParser();
     
      parser.parse(in, new XMLDocumentParser(document));
     
      return document.instance.getInstance();
    } catch (ParserConfigurationException e) {
View Full Code Here

        Query query = XPQueryParser.compile(parsedQuery);
        return query;
    }

    protected void parseXml(String xmlText) throws ParserConfigurationException, SAXException, IOException {
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
        parserFactory.setNamespaceAware(true);
        SAXParser parser = parserFactory.newSAXParser();
        XMLReader xmlReader = parser.getXMLReader();
        xmlReader.setContentHandler(filter);
        xmlReader.setDTDHandler(filter);
        xmlReader.parse(new InputSource(new StringReader(xmlText)));
    }
View Full Code Here

        is.setSystemId(_systemId);

      XMLFilter filter = (XMLFilter) _filter;

      if (xmlReader == null) {
        SAXParserFactory parserFactory = SAXParserFactory.newInstance();
       
        // jsp/1m14
        parserFactory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
        parserFactory.setFeature("http://xml.org/sax/features/namespaces", true);
       
        xmlReader = parserFactory.newSAXParser().getXMLReader();
      }

      // jsp/1g05
      if (_filter != null && _var == null && _varDom == null) {
        filter.setParent(xmlReader);
View Full Code Here

TOP

Related Classes of javax.xml.parsers.SAXParserFactory

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.