Refine search
@Override protected void write(OutputStream out) throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(CTChartsheet.type.getName().getNamespaceURI(), "chartsheet")); chartsheet.save(out, xmlOptions); }
protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) { XmlOptions xo = new XmlOptions(); xo.setCharacterEncoding("UTF-8"); Map<String,String> nsMap = new HashMap<>(); nsMap.put(passwordUri.toString(),"p"); nsMap.put(certificateUri.toString(), "c"); xo.setUseDefaultNamespace(); xo.setSaveSuggestedPrefixes(nsMap); xo.setSaveNamespacesFirst(); xo.setSaveAggressiveNamespaces(); // setting standalone doesn't work with xmlbeans-2.3 & 2.6 // ed.documentProperties().setStandalone(true); xo.setSaveNoXmlDecl(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { bos.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n".getBytes("UTF-8")); ed.save(bos, xo); bos.writeTo(os); } catch (IOException e) { throw new EncryptedDocumentException("error marshalling encryption info document", e); } }
@Beta protected void readFrom(InputStream is) throws IOException { try { XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS); //Removing root element options.setLoadReplaceDocumentElement(null); ctPivotCache = CTPivotCache.Factory.parse(is, options); } catch (XmlException e) { throw new IOException(e.getLocalizedMessage()); } }
@Override protected final void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement( new QName(XSLFRelation.NS_DRAWINGML, "theme")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); getXmlObject().save(out, xmlOptions); out.close(); }
XmlOptions compileOptions = new XmlOptions(); if (options.isNetworkDownloads()) compileOptions.setCompileDownloadUrls(); if (options.isNopvr()) compileOptions.setCompileNoPvrRule(); if (options.isNoupa()) compileOptions.setCompileNoUpaRule(); for (int i = 0; i < globalElems.length; i++) if (rootName.equals(globalElems[i].getDocumentElementName().getLocalPart()))
public void toXML(OutputStream outputStream) throws IOException { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSavePrettyPrintIndent(4); options.setUseDefaultNamespace(); xmlObject.save(outputStream, options); }
try XmlOptions ltgOptions = new XmlOptions(); ltgOptions.setLoadSubstituteNamespaces(Collections.singletonMap("", "http://www.bea.com/2003/05/xmlbean/ltgfmt")); ltgOptions.setErrorListener(errors); ltgOptions.setLoadLineNumbers(); TestsDocument doc = TestsDocument.Factory.parse(ltgFile, ltgOptions); if (!doc.validate(ltgOptions))
public static String indent(String xmldoc) throws IOException, XmlException { StringWriter sw = new StringWriter(); XmlObject doc = XmlObject.Factory.parse(xmldoc, (new XmlOptions()).setLoadLineNumbers()); doc.save(sw, new XmlOptions().setSavePrettyPrint().setSavePrettyPrintIndent(DEFAULT_INDENT)); sw.close(); return sw.getBuffer().toString(); } }
/** * Returns default output options for outputting XmlObjects from XBeans. * * @return */ public static XmlOptions getDefaultXMLOptions() { XmlOptions opts= new XmlOptions(); opts.setSavePrettyPrint(); opts.setSavePrettyPrintIndent(INDENTION_SIZE); return opts; }
public static InputStream createInputStream(XmlObject xmlObject, boolean writeXMLDeclaration) throws GenericException, ValidationException { // Create an XmlOptions instance and set the error listener. XmlOptions validateOptions = new XmlOptions(); List<XmlValidationError> errorList = new ArrayList<>(); validateOptions.setErrorListener(errorList); // Validate the XML. boolean isValid = xmlObject.validate(validateOptions); if (isValid) { XmlOptions xmlSaveOptions = new XmlOptions().setUseDefaultNamespace().setSavePrettyPrint() .setSaveAggressiveNamespaces(); if (!writeXMLDeclaration) { xmlSaveOptions = xmlSaveOptions.setSaveNoXmlDecl(); } return xmlObject.newInputStream(xmlSaveOptions); } else { throw new ValidationException(xmlValidationErrorsToValidationReport(errorList)); } }
private static void addSchema(String name, SchemaDocument schemadoc, XmlErrorWatcher errorListener, boolean noVDoc, List scontentlist) { StscState.addInfo(errorListener, "Loading schema file " + name); XmlOptions opts = new XmlOptions().setErrorListener(errorListener); if (noVDoc) opts.setValidateTreatLaxAsSkip(); if (schemadoc.validate(opts)) scontentlist.add((schemadoc).getSchema()); }
public XmlOptions getSaveOptions( boolean prettyPrint ) { XmlOptions opts = new XmlOptions(); opts.setSaveOuter() ; // opts.setSaveImplicitNamespaces( ImplicitNamespaces ) ; opts.setSaveNamespacesFirst() ; opts.setSaveAggressiveNamespaces() ; if( prettyPrint ) { opts.setSavePrettyPrint() ; opts.setSavePrettyPrintIndent( prettyPrintIndent ) ; } return opts ; }
private static XmlOptions makeXMLOptions() { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setLoadStripWhitespace(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveOuter(); xmlOptions.setUseDefaultNamespace(); xmlOptions.setCompileNoValidation(); xmlOptions.setSaveAggressiveNamespaces(); xmlOptions.setCharacterEncoding(ENCODING); Map<String, String> ns = new HashMap<String, String>(); ns.put("http://www.w3.org/1999/xlink", "xlink"); ns.put("http://purl.org/dc/terms/", "dcterms"); ns.put("http://purl.org/dc/elements/1.1/", "dc"); xmlOptions.setSaveSuggestedPrefixes(ns); return xmlOptions; }
@ApiModelProperty(hidden=true) public XmlOptions getXmlSaveOptions() { XmlOptions options = new XmlOptions(); options.setSavePrettyPrint(); options.setSaveAggressiveNamespaces(); options.setSavePrettyPrintIndent(2); return options; }
public final void writeCache() throws IOException { InputStream input = _importsDoc.newInputStream(new XmlOptions().setSavePrettyPrint()); writeInputStreamToFile(input, getIndexFilename()); }
protected void init(Map<SystemValue, Object> values) throws XMLBindingException{ // Set up xml defaults xopt = new XmlOptions(); HashMap<String, String> uriToPrefixMap = new HashMap<String, String>(); uriToPrefixMap.put(SCHEMA_XSI, "xsi"); uriToPrefixMap.put(SCHEMA_OPENEHR_ORG_V1, "v1"); xopt.setSaveSuggestedPrefixes(uriToPrefixMap); xopt.setSaveAggressiveNamespaces(); xopt.setSavePrettyPrint(); xopt.setCharacterEncoding("UTF-8"); try { builder = new RMObjectBuilder(values); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("failed to start XMLBinding..."); } }
XmlOptions options = new XmlOptions(); options.setLoadLineNumbers(); options.setLoadMessageDigest(); options.setEntityResolver(entResolver); XmlOptions options = new XmlOptions(); options.setLoadLineNumbers(); options.setLoadSubstituteNamespaces(Collections.singletonMap( "http://schemas.xmlsoap.org/wsdl/", "http://www.apache.org/internal/xmlbeans/wsdlsubst" )); options.setEntityResolver(entResolver); XmlOptions options = new XmlOptions(); options.setLoadLineNumbers(); options.setLoadSubstituteNamespaces(Collections.singletonMap("http://schemas.xmlsoap.org/wsdl/", "http://www.apache.org/internal/xmlbeans/wsdlsubst")); options.setEntityResolver(entResolver); XmlOptions options = new XmlOptions(); options.put( XmlOptions.LOAD_LINE_NUMBERS ); options.setEntityResolver(entResolver); options.setLoadSubstituteNamespaces(MAP_COMPATIBILITY_CONFIG_URIS); if (configdoc.validate(new XmlOptions().setErrorListener(errorListener))) XmlOptions opts = new XmlOptions(); if (download) opts.setCompileDownloadUrls(); if (noUpa) opts.setCompileNoUpaRule();
XmlOptions voptions = new XmlOptions(); voptions.setErrorListener(StscState.get().getErrorListener()); if (!(xdoc instanceof SchemaDocument) || !xdoc.validate(voptions))
protected static XmlOptions makeXMLOptions() { XmlOptions xmlOptions = new XmlOptions(); xmlOptions.setSavePrettyPrint(); xmlOptions.setSavePrettyPrintIndent(4); xmlOptions.setSaveOuter(); Map<String, String> prefixes = new HashMap<String, String>(); prefixes.put(PLUGINS_NS, "plugins"); xmlOptions.setSaveSuggestedPrefixes(prefixes); xmlOptions.setUseDefaultNamespace(); xmlOptions.setLoadStripWhitespace(); return xmlOptions; }
try XmlObject schema = XmlObject.Factory.parse(testCase.getSchemaFile(), new XmlOptions().setErrorListener(errors).setLoadLineNumbers()); XmlObject schema2 = null; if (testCase.getResourceFile() != null) schema2 = XmlObject.Factory.parse(testCase.getResourceFile(), new XmlOptions().setErrorListener(errors).setLoadLineNumbers()); XmlObject[] schemas = schema2 == null ? new XmlObject[] { schema } : new XmlObject[] { schema, schema2 }; SchemaTypeSystem system = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), new XmlOptions().setErrorListener(errors)); loader = XmlBeans.typeLoaderUnion(new SchemaTypeLoader[] { system, XmlBeans.getBuiltinTypeSystem() }); XmlObject instance = loader.parse(testCase.getInstanceFile(), null, new XmlOptions().setErrorListener(errors).setLoadLineNumbers()); if (!instance.validate(new XmlOptions().setErrorListener(errors))) instanceValid = false;