本文整理匯總了Java中org.apache.xmlbeans.XmlOptions.setSavePrettyPrint方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlOptions.setSavePrettyPrint方法的具體用法?Java XmlOptions.setSavePrettyPrint怎麽用?Java XmlOptions.setSavePrettyPrint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.xmlbeans.XmlOptions
的用法示例。
在下文中一共展示了XmlOptions.setSavePrettyPrint方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getXmlOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public XmlOptions getXmlOptions() {
HashMap<String,String> suggestedPrefixes = new HashMap<String,String>();
suggestedPrefixes.put("http://www.oscarmcmaster.org/AR2005", "");
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance","xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
opts.setSaveNoXmlDecl();
opts.setUseDefaultNamespace();
Map<String,String> implicitNamespaces = new HashMap<String,String>();
implicitNamespaces.put("","http://www.oscarmcmaster.org/AR2005");
opts.setSaveImplicitNamespaces(implicitNamespaces);
opts.setSaveNamespacesFirst();
opts.setCharacterEncoding("UTF-16");
return opts;
}
示例2: generateXMLAndValidate
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
@Test
public void generateXMLAndValidate() throws Exception {
ARRecordSetDocument recordSetD = ARRecordSetDocument.Factory.newInstance();
ARRecordSet recordSet = recordSetD.addNewARRecordSet();
ARRecord arRecord = recordSet.addNewARRecord();
AR1 ar1 = arRecord.addNewAR1();
populateAr1(ar1);
AR2 ar2 = arRecord.addNewAR2();
populateAr2(ar2);
HashMap<String,String> suggestedPrefixes = new HashMap<String,String>();
suggestedPrefixes.put("http://www.oscarmcmaster.org/AR2005", "");
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance","xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
ArrayList validationErrors = new ArrayList();
XmlOptions m_validationOptions = new XmlOptions();
m_validationOptions.setErrorListener(validationErrors);
recordSetD.validate(m_validationOptions);
for(Object o:validationErrors) {
System.out.println(o);
}
recordSetD.save(new FileOutputStream("ar2005.xml"),opts);
}
示例3: writeXmlObject
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
* Writes the document into given stream. Removes namespace usage from SignedDoc element (Digidoc container) Amphora test
* environment is not capable of receiving such xml
*/
private void writeXmlObject(XmlObject xmlObject, OutputStream outputStream) {
XmlOptions options = new XmlOptions();
options.setCharacterEncoding(DVK_MESSAGE_CHARSET);
{ // fix DigiDoc client bug (also present with PostiPoiss doc-management-system)
// they don't accept that SignedDoc have nameSpace alias set
options.setSavePrettyPrint();
HashMap<String, String> suggestedPrefixes = new HashMap<String, String>(2);
suggestedPrefixes.put("http://www.sk.ee/DigiDoc/v1.3.0#", "");
// suggestedPrefixes.put("http://www.sk.ee/DigiDoc/v1.4.0#", "");
options.setSaveSuggestedPrefixes(suggestedPrefixes);
}
try {
xmlObject.save(outputStream, options);
writeXmlObjectToSentDocumentsFolder(xmlObject, options);
} catch (IOException e) {
log.error("Writing document failed", e);
throw new java.lang.RuntimeException(e);
}
}
示例4: prepareXMLFile
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
* Sends xml to the response
*
* @param wsdlXml the xml object
* @param resp the response object where to send the file
* @throws IOException if IO error
*/
protected String prepareXMLFile(XmlObject wsdlXml,
HttpServletRequest req, HttpServletResponse resp) throws IOException {
if (wsdlXml == null) {
throw new IOException("Could not read wsdl file.");
}
XmlOptions opts = new XmlOptions();
opts.setSaveNamespacesFirst();
opts.setSavePrettyPrint();
opts.setLoadStripComments();
resp.setContentType("text/xml");
return wsdlXml.xmlText(opts);
}
示例5: MzXmlWriter
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
* Constructor creates the XmlBeans representing the shell of a mzXml document, and
* creates the "prefix" and "postscript" strings representing that shell
*/
public MzXmlWriter()
{
//initialize basic document structure and printing options
_xmlBeansMsRunDoc = MsRunDocument.Factory.newInstance();
//Construct generic document structure
_xmlBeansMsRun = _xmlBeansMsRunDoc.addNewMsRun();
//oddly, there's no Index element in the xsd under MsRun, even though that's where we want it
MzXMLDocument fakeMzXmlDoc = MzXMLDocument.Factory.newInstance();
_xmlBeansIndex = fakeMzXmlDoc.addNewMzXML().addNewIndex();
//set printing options for xml fragments
_optionsForPrinting = new XmlOptions();
_optionsForPrinting.setSaveOuter();
_optionsForPrinting.setSavePrettyPrint();
_optionsForPrinting.setSavePrettyPrintOffset(0);
}
示例6: writeXmlFile
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static void writeXmlFile(XmlObject docObject, String targetFilePath) {
File xmlFile = new File(targetFilePath);
HashMap NamespaceMap = new HashMap();
NamespaceMap.put("http://www.opengis.net/om/2.0", "om");
NamespaceMap.put(NS_GML, "gml");
NamespaceMap.put(NS_MET_BASIC, "");
NamespaceMap.put(NS_OPM, "");
NamespaceMap.put(NS_METCE, "metce");
NamespaceMap.put(NS_SAF, "saf");
NamespaceMap.put(NS_IWXXM, "");
NamespaceMap.put(NS_XS, "");
NamespaceMap.put(NS_SAMS, "sams");
NamespaceMap.put(NS_SAM, "sam");
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setSavePrettyPrint();
xmlOptions.setSaveSuggestedPrefixes(NamespaceMap);
xmlOptions.setSaveAggressiveNamespaces();
xmlOptions.setUseDefaultNamespace();
try {
docObject.save(xmlFile, xmlOptions);
} catch (IOException e) {
e.printStackTrace();
}
}
示例7: generateXml
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private byte[] generateXml(LoggedInInfo loggedInInfo, Integer demographicNo, Integer rourkeFdid, Integer nddsFdid, Integer report18mFdid, boolean useClinicInfoForOrganizationId) {
HashMap<String,String> suggestedPrefixes = new HashMap<String,String>();
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance","xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
opts.setSaveNoXmlDecl();
opts.setUseDefaultNamespace();
opts.setSaveNamespacesFirst();
ByteArrayOutputStream os = null;
PrintWriter pw = null;
boolean xmlCreated = false;
BORN18MFormToXML xml = new BORN18MFormToXML(demographicNo);
try {
os = new ByteArrayOutputStream();
pw = new PrintWriter(os, true);
//pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlCreated = xml.addXmlToStream(loggedInInfo, pw, opts, rourkeFdid, nddsFdid, report18mFdid, useClinicInfoForOrganizationId);
pw.close();
if (xmlCreated) return os.toByteArray();
}
catch(Exception e) {
logger.warn("Unable to add record",e);
}
return null;
}
示例8: generateXMLAndValidate
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public void generateXMLAndValidate(LoggedInInfo loggedInInfo, OutputStream os, String providerNo,String demographicNo, int formId, int episodeId) throws Exception {
this.demographicNo = demographicNo;
this.providerNo = providerNo;
this.formId = formId;
this.episodeId = episodeId;
FrmRecord rec = (new FrmRecordFactory()).factory("ONAREnhanced");
props = rec.getFormRecord(loggedInInfo, Integer.parseInt(demographicNo), formId);
ARRecordSetDocument recordSetD = ARRecordSetDocument.Factory.newInstance();
ARRecordSet recordSet = recordSetD.addNewARRecordSet();
ARRecord arRecord = recordSet.addNewARRecord();
AR1 ar1 = arRecord.addNewAR1();
populateAr1(ar1,providerNo);
AR2 ar2 = arRecord.addNewAR2();
populateAr2(ar2);
HashMap<String,String> suggestedPrefixes = new HashMap<String,String>();
suggestedPrefixes.put("http://www.oscarmcmaster.org/AR2005", "");
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance","xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
ArrayList validationErrors = new ArrayList();
XmlOptions m_validationOptions = new XmlOptions();
m_validationOptions.setErrorListener(validationErrors);
recordSetD.validate(m_validationOptions);
for(Object o:validationErrors) {
MiscUtils.getLogger().warn(o);
}
recordSetD.save(os,opts);
}
示例9: generateWBCSDXml
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private byte[] generateWBCSDXml(BORNWbCsdXmlGenerator xml, Integer demographicNo) {
HashMap<String, String> suggestedPrefixes = new HashMap<String, String>();
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
opts.setSaveNoXmlDecl();
opts.setUseDefaultNamespace();
opts.setSaveNamespacesFirst();
ByteArrayOutputStream os = null;
PrintWriter pw = null;
boolean xmlCreated = false;
try {
os = new ByteArrayOutputStream();
pw = new PrintWriter(os, true);
//pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlCreated = xml.addToStream(pw, opts, demographicNo, true);
pw.close();
if (xmlCreated) return os.toByteArray();
} catch (Exception e) {
logger.warn("Unable to add record", e);
}
return null;
}
示例10: generateWBXml
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private byte[] generateWBXml(BORNWbXmlGenerator xml, Integer demographicNo) {
HashMap<String, String> suggestedPrefixes = new HashMap<String, String>();
suggestedPrefixes.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
XmlOptions opts = new XmlOptions();
opts.setSaveSuggestedPrefixes(suggestedPrefixes);
opts.setSavePrettyPrint();
opts.setSaveNoXmlDecl();
opts.setUseDefaultNamespace();
opts.setSaveNamespacesFirst();
ByteArrayOutputStream os = null;
PrintWriter pw = null;
boolean xmlCreated = false;
try {
os = new ByteArrayOutputStream();
pw = new PrintWriter(os, true);
//pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xmlCreated = xml.addToStream(pw, opts, true);
pw.close();
if (xmlCreated) return os.toByteArray();
} catch (Exception e) {
logger.warn("Unable to add record", e);
}
return null;
}
示例11: export
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public ActionForward export(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
if(!surveyUserManager.isAdmin(request)) {
postMessage(request,"survey.auth");
return mapping.findForward("auth");
}
String id = request.getParameter("id");
SurveyDocument survey = surveyManager.getSurveyDocument(id);
if(survey == null) {
postMessage(request,"survey.missing");
return list(mapping,form,request,response);
}
response.setContentType("text/xml");
response.setHeader("Content-disposition","attachement;filename=" + survey.getSurvey().getName() + ".xml");
try {
XmlOptions options = new XmlOptions();
options.setSavePrettyPrint();
options.setSavePrettyPrintIndent(4);
survey.save(response.getWriter(),options);
}catch(Exception e) {
log.error("Error", e);
}
return null;
}
示例12: save
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static boolean save(){
XmlOptions opts = new XmlOptions();
opts.setSavePrettyPrint();
try {
StringWriter doctext = new StringWriter();
doc.save(doctext,opts);
boolean ok = Manager.saveValidator(doctext.toString());
return ok;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
示例13: save
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static boolean save(){
XmlOptions opts = new XmlOptions();
opts.setSavePrettyPrint();
try {
ByteArrayOutputStream doctext = new ByteArrayOutputStream();
doc.save(doctext,opts);
boolean ok = Manager.saveEnv(doctext.toString("UTF-8"));
return ok;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
示例14: getClassToXML
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
* XML데이터를 XML파일로 저장
*
* @param UserinfoDocument
* userDoc 사용자 임의 클래스(XML스키마를 통해 생성된 자바클래스)
* @param String
* fiile 저장될 파일
* @return boolean 저장여부 True / False
* @exception Exception
*/
public static boolean getClassToXML(SndngMailDocument mailDoc, String file) throws Exception {
boolean result = false;
FileOutputStream fos = null;
try {
String file1 = file.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR);
file1 = FileTool.createNewFile(file1);
File xmlFile = new File(WebUtil.filePathBlackList(file1));
fos = new FileOutputStream(xmlFile);
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setSavePrettyPrint();
xmlOptions.setSavePrettyPrintIndent(4);
xmlOptions.setCharacterEncoding("UTF-8");
String xmlStr = mailDoc.xmlText(xmlOptions);
fos.write(xmlStr.getBytes("UTF-8"));
result = true;
} catch (Exception ex) {
// ex.printStackTrace();
throw ex; // 2011.10.10 보안점검 후속조치
} finally {
if (fos != null)
fos.close();
}
return result;
}
示例15: getXmlSaveOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
@ApiModelProperty(hidden=true)
public XmlOptions getXmlSaveOptions() {
XmlOptions options = new XmlOptions();
options.setSavePrettyPrint();
options.setSaveAggressiveNamespaces();
options.setSavePrettyPrintIndent(2);
return options;
}