SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); ParserAdapter adapter = new ParserAdapter(parser.getParser()); adapter.setEntityResolver(entityResolver); adapter.setContentHandler(documentFilter); adapter.parse(requestSource); LOGGER.fine("just parsed: " + requestSource); } catch (SAXException e) {
checkNotParsing("feature", name); namespaces = value; if (!namespaces && !prefixes) { checkNotParsing("feature", name); prefixes = value; if (!prefixes && !namespaces) { checkNotParsing("feature", name); uris = value; } else {
/** * Process a qualified (prefixed) name. * * <p>If the name has an undeclared prefix, use only the qname * and make an ErrorHandler.error callback in case the app is * interested.</p> * * @param qName The qualified (prefixed) name. * @param isAttribute true if this is an attribute name. * @return The name split into three parts. * @exception SAXException The client may throw * an exception if there is an error callback. */ private String [] processName (String qName, boolean isAttribute, boolean useException) throws SAXException { String parts[] = nsSupport.processName(qName, nameParts, isAttribute); if (parts == null) { if (useException) throw makeException("Undeclared prefix: " + qName); reportError("Undeclared prefix: " + qName); parts = new String[3]; parts[0] = parts[1] = ""; parts[2] = qName.intern(); } return parts; }
reportError("Illegal Namespace prefix: " + prefix); continue; String attName[] = processName(attQName, true, true); atts.addAttribute(attName[0], attName[1], attName[2], type, value); String name[] = processName(qName, false, false); contentHandler.startElement(name[0], name[1], name[2], atts);
public void parse(DefaultHandler handler) throws IOException, SAXException { SAXParser sp = createSaxParser(); ParserAdapter pa = new ParserAdapter(sp.getParser()); pa.setContentHandler(handler); pa.parse(new InputSource(reader)); }
public WeightedDirectedMultigraph<String> readWeightedDirectedMultigraph( File f, Indexer<String> vertexLabels) throws IOException { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); ParserAdapter pa = new ParserAdapter(sp.getParser()); GraphMLParser parser = new GraphMLParser(vertexLabels); pa.setContentHandler(parser); pa.setErrorHandler(parser); pa.parse(new InputSource(new BufferedInputStream(new FileInputStream(f)))); return parser.g; } catch (SAXException saxe) { throw new IOException(saxe); } catch (ParserConfigurationException saxe) { throw new IOException(saxe); } }
newReader = new ParserAdapter((Parser) reader); log( "Using SAX1 parser " + reader.getClass().getName(),
/** * Parse an XML document. * * @param systemId The absolute URL of the document. * @exception java.io.IOException If there is a problem reading * the raw content of the document. * @exception SAXException If there is a problem * processing the document. * @see #parse(org.xml.sax.InputSource) * @see org.xml.sax.Parser#parse(java.lang.String) */ public void parse (String systemId) throws IOException, SAXException { parse(new InputSource(systemId)); }
/** * Construct a new parser adapter. * * <p>Note that the embedded parser cannot be changed once the * adapter is created; to embed a different parser, allocate * a new ParserAdapter.</p> * * @param parser The SAX1 parser to embed. * @exception java.lang.NullPointerException If the parser parameter * is null. */ public ParserAdapter (Parser parser) { setup(parser); }
/** * Report a non-fatal error. * * @param message The error message. * @exception SAXException The client may throw * an exception. */ void reportError (String message) throws SAXException { if (errorHandler != null) errorHandler.error(makeException(message)); }
/** * Parse an XML document. * * @param input An input source for the document. * @exception java.io.IOException If there is a problem reading * the raw content of the document. * @exception SAXException If there is a problem * processing the document. * @see #parse(java.lang.String) * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource) */ public void parse (InputSource input) throws IOException, SAXException { if (parsing) { throw new SAXException("Parser is already in use"); } setupParser(); parsing = true; try { parser.parse(input); } finally { parsing = false; } parsing = false; }
String names[] = processName(qName, false, false); if (contentHandler != null) { contentHandler.endElement(names[0], names[1], names[2]);
public void parse(DefaultHandler handler) throws IOException, SAXException { SAXParser sp = createSaxParser(); ParserAdapter pa = new ParserAdapter(sp.getParser()); pa.setContentHandler(handler); pa.parse(new InputSource(reader)); }
ParserAdapter pa = new ParserAdapter(sp.getParser()); parser = new XGMMLParser(); pa.setContentHandler(parser); pa.setErrorHandler(parser); pa.parse(new InputSource(networkStream)); networkName = parser.getNetworkName(); } catch (OutOfMemoryError oe) {
return new ParserAdapter (ParserFactory.makeParser ()); } catch (Exception e) { throw new SAXException ("Can't create default XMLReader; "
/** * Parse an XML document. * * @param systemId The absolute URL of the document. * @exception java.io.IOException If there is a problem reading * the raw content of the document. * @exception SAXException If there is a problem * processing the document. * @see #parse(org.xml.sax.InputSource) * @see org.xml.sax.Parser#parse(java.lang.String) */ public void parse (String systemId) throws IOException, SAXException { parse(new InputSource(systemId)); }
reportError("Illegal Namespace prefix: " + prefix); continue; String attName[] = processName(attQName, true, true); atts.addAttribute(attName[0], attName[1], attName[2], type, value); String name[] = processName(qName, false, false); contentHandler.startElement(name[0], name[1], name[2], atts);
setup(ParserFactory.makeParser()); } catch (ClassNotFoundException e1) { throw new
/** * Report a non-fatal error. * * @param message The error message. * @exception SAXException The client may throw * an exception. */ void reportError (String message) throws SAXException { if (errorHandler != null) errorHandler.error(makeException(message)); }
/** * Parse an XML document. * * @param input An input source for the document. * @exception java.io.IOException If there is a problem reading * the raw content of the document. * @exception SAXException If there is a problem * processing the document. * @see #parse(java.lang.String) * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource) */ public void parse (InputSource input) throws IOException, SAXException { if (parsing) { throw new SAXException("Parser is already in use"); } setupParser(); parsing = true; try { parser.parse(input); } finally { parsing = false; } parsing = false; }