/** * Parse from URI. * @param uri the URI of the document * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.lang.String) */ @Override public Document build(String uri) throws ParsingException, ValidityException, IOException { return build(new InputSource(uri)); }
/** * This is a catch-all convenience method for setting name, xmlns, content space, * content non-XML char and comment policies in one go. This does not affect the * streamability policy or doctype reporting. * * @param xmlPolicy */ public void setXmlPolicy(XmlViolationPolicy xmlPolicy) { setNamePolicy(xmlPolicy); setXmlnsPolicy(xmlPolicy == XmlViolationPolicy.FATAL ? XmlViolationPolicy.ALTER_INFOSET : xmlPolicy); setContentSpacePolicy(xmlPolicy); setContentNonXmlCharPolicy(xmlPolicy); setCommentPolicy(xmlPolicy); }
/** * Parse from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Document build(InputSource is) throws ParsingException, IOException { lazyInit(); treeBuilder.setFragmentContext(null); tokenize(is); return treeBuilder.getDocument(); }
/** * Constructor with given node factory and given XML violation policy. * @param nodeFactory the factory * @param xmlPolicy the policy */ public HtmlBuilder(SimpleNodeFactory nodeFactory, XmlViolationPolicy xmlPolicy) { super(); this.simpleNodeFactory = nodeFactory; this.treeBuilder = new XOMTreeBuilder(nodeFactory); this.driver = null; setXmlPolicy(xmlPolicy); }
/** * This class wraps different tree builders depending on configuration. This * method does the work of hiding this from the user of the class. */ private void lazyInit() { if (driver == null) { this.driver = new Driver(newTokenizer(treeBuilder, false)); this.driver.setErrorHandler(errorHandler); this.driver.setTransitionHandler(transitionHandler); this.treeBuilder.setErrorHandler(treeBuilderErrorHandler); this.driver.setCheckingNormalization(checkingNormalization); this.driver.setCommentPolicy(commentPolicy); this.driver.setContentNonXmlCharPolicy(contentNonXmlCharPolicy); this.driver.setContentSpacePolicy(contentSpacePolicy); this.driver.setMappingLangToXmlLang(mappingLangToXmlLang); this.driver.setXmlnsPolicy(xmlnsPolicy); this.driver.setHeuristics(heuristics); for (CharacterHandler characterHandler : characterHandlers) { this.driver.addCharacterHandler(characterHandler); } this.treeBuilder.setDocumentModeHandler(documentModeHandler); this.treeBuilder.setScriptingEnabled(scriptingEnabled); this.treeBuilder.setReportingDoctype(reportingDoctype); this.treeBuilder.setNamePolicy(namePolicy); } }
/** * Parse from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Document build(InputSource is) throws ParsingException, IOException { lazyInit(); treeBuilder.setFragmentContext(null); tokenize(is); return treeBuilder.getDocument(); }
/** * Constructor with given node factory and given XML violation policy. * @param nodeFactory the factory * @param xmlPolicy the policy */ public HtmlBuilder(SimpleNodeFactory nodeFactory, XmlViolationPolicy xmlPolicy) { super(); this.simpleNodeFactory = nodeFactory; this.treeBuilder = new XOMTreeBuilder(nodeFactory); this.driver = null; setXmlPolicy(xmlPolicy); }
/** * This class wraps different tree builders depending on configuration. This * method does the work of hiding this from the user of the class. */ private void lazyInit() { if (driver == null) { this.driver = new Driver(newTokenizer(treeBuilder, false)); this.driver.setErrorHandler(errorHandler); this.driver.setTransitionHandler(transitionHandler); this.treeBuilder.setErrorHandler(treeBuilderErrorHandler); this.driver.setCheckingNormalization(checkingNormalization); this.driver.setCommentPolicy(commentPolicy); this.driver.setContentNonXmlCharPolicy(contentNonXmlCharPolicy); this.driver.setContentSpacePolicy(contentSpacePolicy); this.driver.setMappingLangToXmlLang(mappingLangToXmlLang); this.driver.setXmlnsPolicy(xmlnsPolicy); this.driver.setHeuristics(heuristics); for (CharacterHandler characterHandler : characterHandlers) { this.driver.addCharacterHandler(characterHandler); } this.treeBuilder.setDocumentModeHandler(documentModeHandler); this.treeBuilder.setScriptingEnabled(scriptingEnabled); this.treeBuilder.setReportingDoctype(reportingDoctype); this.treeBuilder.setNamePolicy(namePolicy); } }
/** * This is a catch-all convenience method for setting name, xmlns, content space, * content non-XML char and comment policies in one go. This does not affect the * streamability policy or doctype reporting. * * @param xmlPolicy */ public void setXmlPolicy(XmlViolationPolicy xmlPolicy) { setNamePolicy(xmlPolicy); setXmlnsPolicy(xmlPolicy == XmlViolationPolicy.FATAL ? XmlViolationPolicy.ALTER_INFOSET : xmlPolicy); setContentSpacePolicy(xmlPolicy); setContentNonXmlCharPolicy(xmlPolicy); setCommentPolicy(xmlPolicy); }
/** * Parse from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Document build(InputSource is) throws ParsingException, IOException { lazyInit(); treeBuilder.setFragmentContext(null); tokenize(is); return treeBuilder.getDocument(); }
/** * Parse from <code>InputStream</code>. * @param stream the stream * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.InputStream) */ @Override public Document build(InputStream stream) throws ParsingException, ValidityException, IOException { return build(new InputSource(stream)); }
/** * Constructor with given node factory and given XML violation policy. * @param nodeFactory the factory * @param xmlPolicy the policy */ public HtmlBuilder(SimpleNodeFactory nodeFactory, XmlViolationPolicy xmlPolicy) { super(); this.simpleNodeFactory = nodeFactory; this.treeBuilder = new XOMTreeBuilder(nodeFactory); this.driver = null; this.driver.setXmlnsPolicy(XmlViolationPolicy.ALTER_INFOSET); setXmlPolicy(xmlPolicy); }
/** * This class wraps different tree builders depending on configuration. This * method does the work of hiding this from the user of the class. */ private void lazyInit() { if (driver == null) { this.driver = new Driver(newTokenizer(treeBuilder, false)); this.driver.setErrorHandler(errorHandler); this.driver.setTransitionHandler(transitionHandler); this.treeBuilder.setErrorHandler(treeBuilderErrorHandler); this.driver.setCheckingNormalization(checkingNormalization); this.driver.setCommentPolicy(commentPolicy); this.driver.setContentNonXmlCharPolicy(contentNonXmlCharPolicy); this.driver.setContentSpacePolicy(contentSpacePolicy); this.driver.setHtml4ModeCompatibleWithXhtml1Schemata(html4ModeCompatibleWithXhtml1Schemata); this.driver.setMappingLangToXmlLang(mappingLangToXmlLang); this.driver.setXmlnsPolicy(xmlnsPolicy); this.driver.setHeuristics(heuristics); for (CharacterHandler characterHandler : characterHandlers) { this.driver.addCharacterHandler(characterHandler); } this.treeBuilder.setDoctypeExpectation(doctypeExpectation); this.treeBuilder.setDocumentModeHandler(documentModeHandler); this.treeBuilder.setScriptingEnabled(scriptingEnabled); this.treeBuilder.setReportingDoctype(reportingDoctype); this.treeBuilder.setNamePolicy(namePolicy); } }
/** * This is a catch-all convenience method for setting name, xmlns, content space, * content non-XML char and comment policies in one go. This does not affect the * streamability policy or doctype reporting. * * @param xmlPolicy */ public void setXmlPolicy(XmlViolationPolicy xmlPolicy) { setNamePolicy(xmlPolicy); setXmlnsPolicy(xmlPolicy == XmlViolationPolicy.FATAL ? XmlViolationPolicy.ALTER_INFOSET : xmlPolicy); setContentSpacePolicy(xmlPolicy); setContentNonXmlCharPolicy(xmlPolicy); setCommentPolicy(xmlPolicy); }
/** * Parse a fragment from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @param context the name of the context element * @return the fragment * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Nodes buildFragment(InputSource is, String context) throws IOException, ParsingException { lazyInit(); treeBuilder.setFragmentContext(context.intern()); tokenize(is); return treeBuilder.getDocumentFragment(); }
/** * Parse from <code>InputStream</code>. * @param stream the stream * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.InputStream) */ @Override public Document build(InputStream stream) throws ParsingException, ValidityException, IOException { return build(new InputSource(stream)); }
/** * Parse a fragment from SAX <code>InputSource</code>. * @param is the <code>InputSource</code> * @param contextLocal the local name of the context element * @parem contextNamespace the namespace of the context element * @return the fragment * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Nodes buildFragment(InputSource is, String contextLocal, String contextNamespace) throws IOException, ParsingException { lazyInit(); treeBuilder.setFragmentContext(contextLocal.intern(), contextNamespace.intern(), null, false); tokenize(is); return treeBuilder.getDocumentFragment(); }
/** * Parse from <code>Reader</code>. * @param stream the reader * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.io.Reader) */ @Override public Document build(Reader stream) throws ParsingException, ValidityException, IOException { return build(new InputSource(stream)); }
/** * Parse a fragment from SAX <code>InputSource</code> assuming an HTML * context. * @param is the <code>InputSource</code> * @param context the name of the context element (HTML namespace assumed) * @return the fragment * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang */ public Nodes buildFragment(InputSource is, String context) throws IOException, ParsingException { lazyInit(); treeBuilder.setFragmentContext(context.intern()); tokenize(is); return treeBuilder.getDocumentFragment(); }
/** * Parse from <code>String</code>. * @param content the HTML source as string * @param uri the base URI * @return the document * @throws ParsingException in case of an XML violation * @throws IOException if IO goes wrang * @see nu.xom.Builder#build(java.lang.String, java.lang.String) */ @Override public Document build(String content, String uri) throws ParsingException, ValidityException, IOException { return build(new StringReader(content), uri); }