/** * Sets the character stream. If the character stream is not already * opened when this object is instantiated, then the code that opens * the stream should also set the character stream on this object. * Also, the encoding of the byte stream used by the reader should * also be set on this object, if known. * * @param charStream The new character stream. * * @see #setEncoding */ public void setCharacterStream(Reader charStream) { super.setCharacterStream(charStream); if (fInputSource == null) { fInputSource = new InputSource(); } fInputSource.setCharacterStream(charStream); } // setCharacterStream(Reader)
@Override public void endElement(QName element, Augmentations augs) throws XNIException { if (currentOsmlTag != null && "script".equalsIgnoreCase(element.rawname)) { QName endingTag = currentOsmlTag; currentOsmlTag = null; XMLInputSource scriptSource = new XMLInputSource(null, null, null); scriptSource.setCharacterStream(new StringReader(scriptContent.toString())); scriptContent.setLength(0); // Evaluate the content of the script block immediately scanner.evaluateInputSource(scriptSource); super.endElement(endingTag, augs); } else { super.endElement(element, augs); } }
@Override public void endElement(QName element, Augmentations augs) throws XNIException { if (currentOsmlTag != null && "script".equalsIgnoreCase(element.rawname)) { QName endingTag = currentOsmlTag; currentOsmlTag = null; XMLInputSource scriptSource = new XMLInputSource(null, null, null); scriptSource.setCharacterStream(new StringReader(scriptContent.toString())); scriptContent.setLength(0); // Evaluate the content of the script block immediately scanner.evaluateInputSource(scriptSource); super.endElement(endingTag, augs); } else { super.endElement(element, augs); } }
private static XMLInputSource toXMLInputSource(InputSource in) { XMLInputSource xin = new XMLInputSource(in.getPublicId(), in.getSystemId(), null); xin.setByteStream(in.getByteStream()); xin.setCharacterStream(in.getCharacterStream()); xin.setEncoding(in.getEncoding()); return xin; } }
private static XMLInputSource toXMLInputSource(InputSource in) { XMLInputSource xin = new XMLInputSource(in.getPublicId(), in.getSystemId(), null); xin.setByteStream(in.getByteStream()); xin.setCharacterStream(in.getCharacterStream()); xin.setEncoding(in.getEncoding()); return xin; } }
private void validateAnnotations(ArrayList annotationInfo) { if (fAnnotationValidator == null) { createAnnotationValidator(); } final int size = annotationInfo.size(); final XMLInputSource src = new XMLInputSource(null, null, null); fGrammarBucketAdapter.refreshGrammars(fGrammarBucket); for (int i = 0; i < size; i += 2) { src.setSystemId((String) annotationInfo.get(i)); XSAnnotationInfo annotation = (XSAnnotationInfo) annotationInfo.get(i+1); while (annotation != null) { src.setCharacterStream(new StringReader(annotation.fAnnotation)); try { fAnnotationValidator.parse(src); } catch (IOException exc) {} annotation = annotation.next; } } }
/** * Creates an XMLInputSource from a SAX InputSource. */ private XMLInputSource createXMLInputSource(InputSource source, String baseURI) { String publicId = source.getPublicId(); String systemId = source.getSystemId(); String baseSystemId = baseURI; InputStream byteStream = source.getByteStream(); Reader charStream = source.getCharacterStream(); String encoding = source.getEncoding(); XMLInputSource xmlInputSource = new XMLInputSource(publicId, systemId, baseSystemId); xmlInputSource.setByteStream(byteStream); xmlInputSource.setCharacterStream(charStream); xmlInputSource.setEncoding(encoding); return xmlInputSource; } // createXMLInputSource(InputSource,String):XMLInputSource
/** Parses a document fragment. */ public void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException { fCurrentNode = fDocumentFragment = fragment; fDocument = fDocumentFragment.getOwnerDocument(); try { String pubid = source.getPublicId(); String sysid = source.getSystemId(); String encoding = source.getEncoding(); InputStream stream = source.getByteStream(); Reader reader = source.getCharacterStream(); XMLInputSource inputSource = new XMLInputSource(pubid, sysid, sysid); inputSource.setEncoding(encoding); inputSource.setByteStream(stream); inputSource.setCharacterStream(reader); fParserConfiguration.parse(inputSource); } catch (XMLParseException e) { Exception ex = e.getException(); if (ex != null) { throw new SAXParseException(e.getMessage(), null, ex); } throw new SAXParseException(e.getMessage(), null); } } // parse(InputSource,DocumentFragment)
/** Parses a document fragment. */ public void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException { fCurrentNode = fDocumentFragment = fragment; fDocument = fDocumentFragment.getOwnerDocument(); try { final String pubid = source.getPublicId(); final String sysid = source.getSystemId(); final String encoding = source.getEncoding(); final InputStream stream = source.getByteStream(); final Reader reader = source.getCharacterStream(); final XMLInputSource inputSource = new XMLInputSource(pubid, sysid, sysid); inputSource.setEncoding(encoding); inputSource.setByteStream(stream); inputSource.setCharacterStream(reader); fParserConfiguration.parse(inputSource); } catch (final XMLParseException e) { final Exception ex = e.getException(); if (ex != null) { throw new SAXParseException(e.getMessage(), null, ex); } throw new SAXParseException(e.getMessage(), null); } }
/** * Parses a document fragment. */ public void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException { fCurrentNode = fDocumentFragment = fragment; fDocument = fDocumentFragment.getOwnerDocument(); try { String pubid = source.getPublicId(); String sysid = source.getSystemId(); String encoding = source.getEncoding(); InputStream stream = source.getByteStream(); Reader reader = source.getCharacterStream(); XMLInputSource inputSource = new XMLInputSource(pubid, sysid, sysid); inputSource.setEncoding(encoding); inputSource.setByteStream(stream); inputSource.setCharacterStream(reader); fParserConfiguration.parse(inputSource); } catch (XMLParseException e) { Exception ex = e.getException(); if (ex != null) { throw new SAXParseException(e.getMessage(), null, ex); } throw new SAXParseException(e.getMessage(), null); } } // parse(InputSource,DocumentFragment)
/** * Parses a document fragment. */ public void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException { fCurrentNode = fDocumentFragment = fragment; fDocument = fDocumentFragment.getOwnerDocument(); try { String pubid = source.getPublicId(); String sysid = source.getSystemId(); String encoding = source.getEncoding(); InputStream stream = source.getByteStream(); Reader reader = source.getCharacterStream(); XMLInputSource inputSource = new XMLInputSource(pubid, sysid, sysid); inputSource.setEncoding(encoding); inputSource.setByteStream(stream); inputSource.setCharacterStream(reader); fParserConfiguration.parse(inputSource); } catch (XMLParseException e) { Exception ex = e.getException(); if (ex != null) { throw new SAXParseException(e.getMessage(), null, ex); } throw new SAXParseException(e.getMessage(), null); } } // parse(InputSource,DocumentFragment)
/** Parses a document fragment. */ public void parse(InputSource source, DocumentFragment fragment) throws SAXException, IOException { fCurrentNode = fDocumentFragment = fragment; fDocument = fDocumentFragment.getOwnerDocument(); try { String pubid = source.getPublicId(); String sysid = source.getSystemId(); String encoding = source.getEncoding(); InputStream stream = source.getByteStream(); Reader reader = source.getCharacterStream(); XMLInputSource inputSource = new XMLInputSource(pubid, sysid, sysid); inputSource.setEncoding(encoding); inputSource.setByteStream(stream); inputSource.setCharacterStream(reader); fParserConfiguration.parse(inputSource); } catch (XMLParseException e) { Exception ex = e.getException(); if (ex != null) { throw new SAXParseException(e.getMessage(), null, ex); } throw new SAXParseException(e.getMessage(), null); } } // parse(InputSource,DocumentFragment)
new XMLInputSource(publicId, systemId, baseSystemId); xmlInputSource.setByteStream(byteStream); xmlInputSource.setCharacterStream(charStream); xmlInputSource.setEncoding(encoding); return xmlInputSource;
null); xmlInputSource.setByteStream(inputSource.getByteStream()); xmlInputSource.setCharacterStream(inputSource.getCharacterStream()); xmlInputSource.setEncoding(inputSource.getEncoding()); parse(xmlInputSource);
null); xmlInputSource.setByteStream(inputSource.getByteStream()); xmlInputSource.setCharacterStream(inputSource.getCharacterStream()); xmlInputSource.setEncoding(inputSource.getEncoding()); parse(xmlInputSource);
xmlInputSource.setCharacterStream(charStream); xmlInputSource.setCharacterStream(new StringReader(data));
XMLInputSource input = new XMLInputSource(streamSource.getPublicId(), streamSource.getSystemId(), null); input.setByteStream(streamSource.getInputStream()); input.setCharacterStream(streamSource.getReader());
/** * Parse HTML source. * * @return a document handler containing the parsed source */ private DocumentHandler parseHtmlImpl(String source, HTMLConfiguration config, NormalizingTagBalancer tagBalancer) throws IOException { HTMLScanner htmlScanner = new HTMLScanner(); tagBalancer.setScanner(htmlScanner); DocumentHandler handler = newDocumentHandler(source); NamespaceBinder namespaceBinder = new NamespaceBinder(); namespaceBinder.setDocumentHandler(handler); namespaceBinder.setDocumentSource(tagBalancer); namespaceBinder.reset(config); tagBalancer.setDocumentHandler(namespaceBinder); // Order of filter is Scanner -> OSMLFilter -> Tag Balancer tagBalancer.setDocumentSource(htmlScanner); htmlScanner.setDocumentHandler(tagBalancer); tagBalancer.reset(config); htmlScanner.reset(config); XMLInputSource inputSource = new XMLInputSource(null, null, null); inputSource.setEncoding("UTF-8"); inputSource.setCharacterStream(new StringReader(source)); htmlScanner.setInputSource(inputSource); htmlScanner.scanDocument(true); return handler; }
/** * Parse HTML source. * * @return a document handler containing the parsed source */ private DocumentHandler parseHtmlImpl(String source, HTMLConfiguration config, NormalizingTagBalancer tagBalancer) throws IOException { HTMLScanner htmlScanner = new HTMLScanner(); tagBalancer.setScanner(htmlScanner); DocumentHandler handler = newDocumentHandler(source); NamespaceBinder namespaceBinder = new NamespaceBinder(); namespaceBinder.setDocumentHandler(handler); namespaceBinder.setDocumentSource(tagBalancer); namespaceBinder.reset(config); tagBalancer.setDocumentHandler(namespaceBinder); // Order of filter is Scanner -> OSMLFilter -> Tag Balancer tagBalancer.setDocumentSource(htmlScanner); htmlScanner.setDocumentHandler(tagBalancer); tagBalancer.reset(config); htmlScanner.reset(config); XMLInputSource inputSource = new XMLInputSource(null, null, null); inputSource.setEncoding("UTF-8"); inputSource.setCharacterStream(new StringReader(source)); htmlScanner.setInputSource(inputSource); htmlScanner.scanDocument(true); return handler; }
/** * Parse HTML source. * * @return a document handler containing the parsed source */ private DocumentHandler parseHtmlImpl(String source, HTMLConfiguration config, NormalizingTagBalancer tagBalancer) throws IOException { HTMLScanner htmlScanner = new HTMLScanner(); tagBalancer.setScanner(htmlScanner); DocumentHandler handler = newDocumentHandler(source); NamespaceBinder namespaceBinder = new NamespaceBinder(); namespaceBinder.setDocumentHandler(handler); namespaceBinder.setDocumentSource(tagBalancer); namespaceBinder.reset(config); tagBalancer.setDocumentHandler(namespaceBinder); // Order of filter is Scanner -> OSMLFilter -> Tag Balancer tagBalancer.setDocumentSource(htmlScanner); htmlScanner.setDocumentHandler(tagBalancer); tagBalancer.reset(config); htmlScanner.reset(config); XMLInputSource inputSource = new XMLInputSource(null, null, null); inputSource.setEncoding("UTF-8"); inputSource.setCharacterStream(new StringReader(source)); htmlScanner.setInputSource(inputSource); htmlScanner.scanDocument(true); return handler; }