protected void createDocumentIfNecessary() { if (document == null && parser.getEventType() == XMLStreamReader.START_DOCUMENT) { document = createDocument(); if (charEncoding != null) { document.setCharsetEncoding(charEncoding); } document.setXMLVersion(parser.getVersion()); document.setXMLEncoding(parser.getCharacterEncodingScheme()); document.setStandalone(parser.isStandalone() ? "yes" : "no"); target = (OMContainerEx)document; } }
public FOMBuilder(FOMFactory factory, XMLStreamReader parser, ParserOptions parserOptions) { super(factory, new FOMStAXFilter(parser, parserOptions)); this.document = (OMDocument)factory.newDocument(); this.parserOptions = parserOptions; this.fomfactory = factory; String enc = parser.getCharacterEncodingScheme(); document.setCharsetEncoding(enc != null ? enc : "utf-8"); document.setXMLVersion(parser.getVersion() != null ? parser.getVersion() : "1.0"); }
private <T extends Element> Document<T> getDocument(FOMBuilder builder, IRI base, ParserOptions options) throws ParseException { Document<T> document = builder.getFomDocument(); try { if (base != null) document.setBaseUri(base.toString()); if (options != null && options.getCharset() != null) ((OMDocument)document).setCharsetEncoding(options.getCharset()); if (options != null) document.setMustPreserveWhitespace(options.getMustPreserveWhitespace()); } catch (Exception e) { if (!(e instanceof ParseException)) e = new ParseException(e); throw (ParseException)e; } return document; }