當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlOptions.setSavePrettyPrint方法代碼示例

本文整理匯總了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;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:18,代碼來源:ONAREnhancedBornConnector.java

示例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);
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:25,代碼來源:AR2005XMLTest.java

示例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);
    }
}
 
開發者ID:nortal,項目名稱:j-road,代碼行數:24,代碼來源:DhlXTeeServiceImpl.java

示例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);
}
 
開發者ID:52North,項目名稱:SES,代碼行數:23,代碼來源:GetRequestHandler.java

示例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);
}
 
開發者ID:dhmay,項目名稱:msInspect,代碼行數:24,代碼來源:MzXmlWriter.java

示例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();
        }
    }
 
開發者ID:saeidrastak,項目名稱:IWXXMConverter,代碼行數:31,代碼來源:CommonUtils.java

示例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;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:30,代碼來源:BORN18MConnector.java

示例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);
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:31,代碼來源:ONAREnhancedFormToXML.java

示例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;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:28,代碼來源:BORNWBCSDJob.java

示例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;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:28,代碼來源:BORNWBJob.java

示例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;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:28,代碼來源:SurveyManagerAction.java

示例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;
}
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:14,代碼來源:ValidatorOptions.java

示例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;
}
}
 
開發者ID:unsftn,項目名稱:bisis-v4,代碼行數:14,代碼來源:EnvironmentOptions.java

示例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;
}
 
開發者ID:aramsoft,項目名稱:aramcomp,代碼行數:43,代碼來源:XMLDoc.java

示例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;
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:9,代碼來源:XmlBeanWrapper.java


注:本文中的org.apache.xmlbeans.XmlOptions.setSavePrettyPrint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。