static public IncrementalSAXSource createIncrementalSAXSource() { try { return new IncrementalSAXSource_Xerces(); } catch(NoSuchMethodException e) { // Xerces version mismatch; neither Xerces1 nor Xerces2 succeeded. // Fall back on filtering solution. IncrementalSAXSource_Filter iss=new IncrementalSAXSource_Filter(); iss.setXMLReader(new SAXParser()); return iss; } }
protected SAXParser parser() throws ParserConfigurationException, SAXException { SAXParser parser = new SAXParser(); parser.setFeature("http://xml.org/sax/features/namespaces", true); parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", schemaLocation.toString()); parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", handler.getConfiguration().getSchemaFileURL());
public void parse() throws SAXException, IOException { SAXParser parser = new SAXParser(); parser.setContentHandler(ch); //TODO: Make sure that the ContentHandler is "reset". parser.parse(getInputSource()); }
/** * Parses an instance documented defined by a sax input source. * <p> * The object returned from the parse is the object which has been bound to the root * element of the document. This method should only be called once for a single instance document. * </p> * * @return The object representation of the root element of the document. * * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public Object parse(InputSource source) throws IOException, SAXException, ParserConfigurationException { parser = parser(); parser.setContentHandler(handler); parser.setErrorHandler(handler); parser.parse(source); return handler.getValue(); }
parser = new SAXParser(config); fParser = new SoftReference(parser); parser.reset(); parser.setContentHandler(ser.asContentHandler());
private synchronized void writeToSAX(ContentHandler handler) { // nothing must go wrong with this parse... SAXParser parser = fGrammar.getSAXParser(); StringReader aReader = new StringReader(fData); InputSource aSource = new InputSource(aReader); parser.setContentHandler(handler); try { parser.parse(aSource); } catch (SAXException e) { // this should never happen! // REVISIT: what to do with this?; should really not // eat it... } catch (IOException i) { // ditto with above } // Release the reference to the user's ContentHandler. parser.setContentHandler(null); }
private ARPFilter(SAXParser rdr, XMLPullParserConfiguration config) { super(rdr); pullParser = config; saxParser = rdr; rdr.setEntityResolver(this); rdr.setDTDHandler(this); rdr.setContentHandler(this); rdr.setErrorHandler(this); setErrorHandler(new DefaultErrorHandler()); }
saxParser.setFeature("http://xml.org/sax/features/namespaces", true); saxParser.setFeature( "http://xml.org/sax/features/namespace-prefixes", true); saxParser.setProperty( "http://xml.org/sax/properties/lexical-handler", this); saxParser.reset();
Object old; try { old = arpf.getSAXParser().getProperty(str); } catch (SAXNotSupportedException ns) { old = null; arpf.getSAXParser().setProperty(str, obj); } catch (SAXNotSupportedException ns) { errorHandler.error(new JenaException(ns)); Boolean old; try { old = new Boolean(arpf.getSAXParser().getFeature(str)); } catch (SAXNotSupportedException ns) { old = null; arpf.getSAXParser().setFeature(str, ((Boolean) obj).booleanValue()); } catch (SAXNotSupportedException ns) {
synchronized public void parse(InputSource input, String base) throws IOException, SAXException { // Make sure we have a sane state for // Namespace processing. initParse(base,""); SAX2RDF.installHandlers(saxParser, this); saxParser.reset(); initEncodingChecks(input); try { saxParser.parse(input); } catch (UTFDataFormatException e) { generalError(ERR_UTF_ENCODING, e); } catch (IOException e) { generalError(ERR_GENERIC_IO, e); } catch (WrappedException wrapped) { wrapped.throwMe(); } catch (FatalParsingErrorException e) { // ignore this. } finally { afterParse(); } }
synchronized void restoreInitState() throws SAXNotRecognizedException, SAXNotSupportedException { Iterator iter; if (!fInitFeatures.isEmpty()) { iter = fInitFeatures.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); boolean value = ((Boolean) entry.getValue()).booleanValue(); super.setFeature(name, value); } fInitFeatures.clear(); } if (!fInitProperties.isEmpty()) { iter = fInitProperties.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); super.setProperty(name, value); } fInitProperties.clear(); } }
public void parse(String systemId) throws SAXException, IOException { if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { if (fSAXParser.fSchemaValidationManager != null) { fSAXParser.fSchemaValidationManager.reset(); fSAXParser.fUnparsedEntityHandler.reset(); } resetSchemaValidator(); } super.parse(systemId); }
boolean current = super.getFeature(name); fInitFeatures.put(name, current ? Boolean.TRUE : Boolean.FALSE); setSchemaValidatorFeature(name, value); super.setFeature(name, value);
fInitProperties.put(JAXP_SCHEMA_LANGUAGE, super.getProperty(JAXP_SCHEMA_LANGUAGE)); super.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); if ( val != null && W3C_XML_SCHEMA.equals(val) ) { if (!fInitProperties.containsKey(JAXP_SCHEMA_SOURCE)) { fInitProperties.put(JAXP_SCHEMA_SOURCE, super.getProperty(JAXP_SCHEMA_SOURCE)); super.setProperty(name, value); fInitProperties.put(name, super.getProperty(name)); setSchemaValidatorProperty(name, value); super.setProperty(name, value);
void setFeature0(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { super.setFeature(name, value); }
void setProperty0(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { super.setProperty(name, value); }
protected SAXParser parser() throws ParserConfigurationException, SAXException { SAXParser parser = new SAXParser(); parser.setFeature("http://xml.org/sax/features/namespaces", true); parser.setFeature("http://xml.org/sax/features/validation", true); parser.setFeature("http://apache.org/xml/features/validation/schema", true); parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation", schemaLocation.toString()); parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", handler.getConfiguration().getSchemaFileURL());
private GoHandler getGoResponse( InputStream inputStream ) throws IOException, SAXException { GoHandler goHandler = null; InputSource source = new InputSource( inputStream ); SAXParser parser = new SAXParser(); goHandler = new GoHandler(); parser.setContentHandler( goHandler ); try { parser.parse( source ); } catch( IOException e ) { throw e; } return goHandler; }
/** * Parses an instance documented defined by a sax input source. * <p> * The object returned from the parse is the object which has been bound to the root * element of the document. This method should only be called once for a single instance document. * </p> * * @return The object representation of the root element of the document. * * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public Object parse(InputSource source) throws IOException, SAXException, ParserConfigurationException { parser = parser(); parser.setContentHandler( handler ); parser.setErrorHandler( handler ); parser.parse( source ); return handler.getValue(); }
public void parse(InputSource inputSource) throws SAXException, IOException { if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { if (fSAXParser.fSchemaValidationManager != null) { fSAXParser.fSchemaValidationManager.reset(); fSAXParser.fUnparsedEntityHandler.reset(); } resetSchemaValidator(); } super.parse(inputSource); }