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


Java XmlOptions.setSaveOuter方法代碼示例

本文整理匯總了Java中org.apache.xmlbeans.XmlOptions.setSaveOuter方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlOptions.setSaveOuter方法的具體用法?Java XmlOptions.setSaveOuter怎麽用?Java XmlOptions.setSaveOuter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.xmlbeans.XmlOptions的用法示例。


在下文中一共展示了XmlOptions.setSaveOuter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createSample

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public String createSample( SchemaType sType )
{
	XmlObject object = XmlObject.Factory.newInstance();
	XmlCursor cursor = object.newCursor();
	// Skip the document node
	cursor.toNextToken();
	// Using the type and the cursor, call the utility method to get a
	// sample XML payload for that Schema element
	createSampleForType( sType, cursor );
	// Cursor now contains the sample payload
	// Pretty print the result. Note that the cursor is positioned at the
	// end of the doc so we use the original xml object that the cursor was
	// created upon to do the xmlText() against.

	cursor.dispose();

	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = object.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:26,代碼來源:SampleXmlUtil.java

示例2: createSampleForElement

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static String createSampleForElement( SchemaGlobalElement element )
{
	XmlObject xml = XmlObject.Factory.newInstance();

	XmlCursor c = xml.newCursor();
	c.toNextToken();
	c.beginElement( element.getName() );

	new SampleXmlUtil( false ).createSampleForType( element.getType(), c );

	c.dispose();

	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = xml.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:22,代碼來源:SampleXmlUtil.java

示例3: createSampleForType

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static String createSampleForType( SchemaType sType )
{
	XmlObject object = XmlObject.Factory.newInstance();
	XmlCursor cursor = object.newCursor();
	// Skip the document node
	cursor.toNextToken();
	// Using the type and the cursor, call the utility method to get a
	// sample XML payload for that Schema element
	new SampleXmlUtil( false ).createSampleForType( sType, cursor );
	// Cursor now contains the sample payload
	// Pretty print the result. Note that the cursor is positioned at the
	// end of the doc so we use the original xml object that the cursor was
	// created upon to do the xmlText() against.

	cursor.dispose();
	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
	options.setSaveOuter();
	String result = object.xmlText( options );

	return result;
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:25,代碼來源:SampleXmlUtil.java

示例4: appendBody

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private static void appendBody(CTBody src, String append, boolean first) throws XmlException {
    XmlOptions optionsOuter = new XmlOptions();
    optionsOuter.setSaveOuter();
    String srcString = src.xmlText();
    String prefix = srcString.substring(0,srcString.indexOf(">")+1);

    final String mainPart;
    // exclude template itself in first appending
    if(first) {
        mainPart = "";
    } else {
        mainPart = srcString.substring(srcString.indexOf(">")+1,srcString.lastIndexOf("<"));
    }

    String suffix = srcString.substring( srcString.lastIndexOf("<") );
    String addPart = append.substring(append.indexOf(">") + 1, append.lastIndexOf("<"));
    CTBody makeBody = CTBody.Factory.parse(prefix+mainPart+addPart+suffix);
    src.set(makeBody);
}
 
開發者ID:centic9,項目名稱:poi-mail-merge,代碼行數:20,代碼來源:MailMerge.java

示例5: resolveChildContents

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private String resolveChildContents(
		XmlObject xobj) {
	XmlCursor cur = xobj.newCursor();
	
	XmlOptions opts = new XmlOptions();
	opts.setSaveOuter();
	TokenType type = cur.toNextToken();
	while (cur.hasNextToken()) {
		if (type == TokenType.START) {
			return cur.getObject().xmlText(opts);
		}
		else if (type == TokenType.TEXT) {
			return cur.getChars().trim();
		}
		type = cur.toNextToken();
	}

	return xobj.xmlText(opts);
}
 
開發者ID:52North,項目名稱:SES,代碼行數:20,代碼來源:StoredFilterHandler.java

示例6: 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

示例7: getDefaultOptions

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static XmlOptions getDefaultOptions() {
	XmlOptions options = new XmlOptions();
	options.put(XmlOptions.SAVE_PRETTY_PRINT);
	options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3);
	options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES);

	HashMap<String, String> suggestedPrefix = new HashMap<String, String>();
	suggestedPrefix.put("cds_dt", "cdsd");
	options.setSaveSuggestedPrefixes(suggestedPrefix);
	options.setSaveOuter();
	return options;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:13,代碼來源:DemographicExportHelper.java

示例8: create

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
static public void create(DemographicsDocument.Demographics demographic, List<ReportsReceivedDocument.ReportsReceived> reports, String filepath) {

        OmdCdsDocument omdCdsDoc = OmdCdsDocument.Factory.newInstance();
        OmdCds omdCds = omdCdsDoc.addNewOmdCds();
        PatientRecord patientRecord = omdCds.addNewPatientRecord();

        Demographics HRMdemo = patientRecord.addNewDemographics();

        writeDemographics(demographic, HRMdemo);
        writeReportsReceived(reports, patientRecord);

	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );

        HashMap<String,String> suggestedPrefix = new HashMap<String,String>();
        suggestedPrefix.put("cds_dt","cdsd");
        options.setSaveSuggestedPrefixes(suggestedPrefix);
	options.setSaveOuter();

        File file = new File(filepath);
        try {
            omdCdsDoc.save(file, options);
        } catch (IOException ex) {
            Logger.getLogger(CreateHRMFile.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:29,代碼來源:CreateHRMFile.java

示例9: makeFiles

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private String makeFiles(PatientDocument patientDocument, String tmpDir) throws Exception {
	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );

	options.setSaveOuter();

	String fileName = "Rourke2009Export.xml";
	File xmlFile = new File(tmpDir, fileName);
	try {
		patientDocument.save(xmlFile, options);
	}
	catch(IOException e) {
		MiscUtils.getLogger().error("Cannot write .xml file(s) to export directory " + tmpDir + ".\nPlease check directory permissions.", e);
	}

	ArrayList<File>files = new ArrayList<File>();
	files.add(xmlFile);
	//Zip export files
    String zipName = "rourke2009_export-"+UtilDateUtilities.getToday("yyyy-MM-dd.HH.mm.ss")+".zip";
    if (!Util.zipFiles(files, zipName, tmpDir)) {
    	MiscUtils.getLogger().error("Error! Failed zipping export files");
    }

    //copy zip to document directory
    File zipFile = new File(tmpDir,zipName);
    OscarProperties properties = OscarProperties.getInstance();
    File destDir = new File(properties.getProperty("DOCUMENT_DIR"));
    org.apache.commons.io.FileUtils.copyFileToDirectory(zipFile, destDir);

    //Remove zip & export files from temp dir
    Util.cleanFile(zipName, tmpDir);
    Util.cleanFiles(files);

    return zipName;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:38,代碼來源:RourkeExportAction.java

示例10: appendBody

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
 * Appends the contents of the second body into the first one
 * 
 * @author Tim Kaler / Whitecoast Solutions AG 
 * @since 17.06.2015
 * @param src The first CTBody, will be appended by append
 * @param append The second CTBody, will insert into src
 * @throws Exception
 */
private static void appendBody(CTBody src, CTBody append) throws Exception {
    XmlOptions optionsOuter = new XmlOptions();
    optionsOuter.setSaveOuter();
    String appendString = append.xmlText(optionsOuter);
    String srcString = src.xmlText();
    String prefix = srcString.substring(0,srcString.indexOf(">")+1);
    String mainPart = srcString.substring(srcString.indexOf(">")+1,srcString.lastIndexOf("<"));
    String sufix = srcString.substring( srcString.lastIndexOf("<") );
    String addPart = appendString.substring(appendString.indexOf(">") + 1, appendString.lastIndexOf("<"));
    CTBody makeBody = CTBody.Factory.parse(prefix+mainPart+addPart+sufix);
    src.set(makeBody);
}
 
開發者ID:crash785,項目名稱:PrintEngine,代碼行數:22,代碼來源:WordXHandler.java

示例11: BasePepXmlWriter

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
 * Constructor creates the XmlBeans representing the shell of a PepXml document, and
 * creates the "prefix" and "postscript" strings representing that shell
 */
public BasePepXmlWriter()
{
    //Construct generic document structure
    _xmlBeansPepXmlDoc = MsmsPipelineAnalysisDocument.Factory.newInstance();
    _xmlBeansAnalysis = _xmlBeansPepXmlDoc.addNewMsmsPipelineAnalysis();

    //dhmay adding two attributes required for TPP to parse these files
    Node xsiAtt =
            _xmlBeansAnalysis.getDomNode().getOwnerDocument().createAttribute("xmlns:xsi");
    xsiAtt.setNodeValue(XSI_URL);
    _xmlBeansAnalysis.getDomNode().getAttributes().setNamedItem(xsiAtt);
    Node schemaLocAtt =
            _xmlBeansAnalysis.getDomNode().getOwnerDocument().createAttribute("xsi:schemaLocation");
    schemaLocAtt.setNodeValue(XSD_URL);
    _xmlBeansAnalysis.getDomNode().getAttributes().setNamedItem(schemaLocAtt);


    _firstRunSummary = _xmlBeansAnalysis.addNewMsmsRunSummary();
    _xmlBeansRunSummaryArray = _xmlBeansAnalysis.getMsmsRunSummaryArray();


    //set printing options for xml fragments
    _optionsForPrinting = new XmlOptions();
    _optionsForPrinting.setSaveOuter();
    _optionsForPrinting.setSavePrettyPrint();
    _optionsForPrinting.setSavePrettyPrintOffset(0);


}
 
開發者ID:dhmay,項目名稱:msInspect,代碼行數:34,代碼來源:BasePepXmlWriter.java

示例12: generateStubs

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
protected void generateStubs()
{
    //add a sentinel node that tells us where to split the document to insert entries
    Node amtDatabaseNode = mXmlBeansAmtDatabase.getDomNode();
    Node dummyEntryLocationNode =
            amtDatabaseNode.getOwnerDocument().createElement("SENTINEL_FEATURE_LOCATION");
    amtDatabaseNode.appendChild(dummyEntryLocationNode);

    //set printing options for xml fragments
    _optionsForPrinting = new XmlOptions();
    _optionsForPrinting.setSaveOuter();
    _optionsForPrinting.setSavePrettyPrint();
    _optionsForPrinting.setSavePrettyPrintOffset(0);

    //create and break up the xml that defines the document structure
    String documentShell = mXmlBeansAmtDatabaseDoc.xmlText(_optionsForPrinting);
    String[] halves = documentShell.split("<SENTINEL_FEATURE_LOCATION[^\\/]*\\/>");
    if (halves.length != 2)
    {
        _log.error("Failed to create document shell for writing");
        return;
    }

    _documentPrefix = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + halves[0];
    _documentPostscript = halves[1];

    //remove our dummy node
    amtDatabaseNode.removeChild(dummyEntryLocationNode);
}
 
開發者ID:dhmay,項目名稱:msInspect,代碼行數:30,代碼來源:AmtXmlWriter.java

示例13: makeFiles

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private String makeFiles(Map<String,CiHiCdsDocument> xmlMap, Map<String,String> fileNamesMap, String tmpDir) throws Exception {
	XmlOptions options = new XmlOptions();
	options.put( XmlOptions.SAVE_PRETTY_PRINT );
	options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
	options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );

    HashMap<String,String> suggestedPrefix = new HashMap<String,String>();
    suggestedPrefix.put("cds_dt","cdsd");
    options.setSaveSuggestedPrefixes(suggestedPrefix);

	options.setSaveOuter();

	ArrayList<File> files = new ArrayList<File>();
	int idx = 0;
	CiHiCdsDocument cihiDoc;
	Set<String>xmlKeys = xmlMap.keySet();

	//Save each file
	for( String key: xmlKeys) {
            if (fileNamesMap.get(key)==null) continue;

		cihiDoc = xmlMap.get(key);
		files.add(new File(tmpDir, fileNamesMap.get(key)));

		try {
			cihiDoc.save(files.get(idx), options);
		}
		catch( IOException e ) {
			MiscUtils.getLogger().error("Cannot write .xml file(s) to export directory " + tmpDir + ".\nPlease check directory permissions.", e);
		}
		++idx;
	} //end for

	//Zip export files
    String zipName = "omd_cihi_export-"+UtilDateUtilities.getToday("yyyy-MM-dd.HH.mm.ss")+".zip";
    if (!Util.zipFiles(files, zipName, tmpDir)) {
    	MiscUtils.getLogger().error("Error! Failed zipping export files");
    }

    //copy zip to document directory
    File zipFile = new File(tmpDir,zipName);
    OscarProperties properties = OscarProperties.getInstance();
    File destDir = new File(properties.getProperty("DOCUMENT_DIR"));
    org.apache.commons.io.FileUtils.copyFileToDirectory(zipFile, destDir);

    //Remove zip & export files from temp dir
    Util.cleanFile(zipName, tmpDir);
    Util.cleanFiles(files);

    return zipName;
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:52,代碼來源:CihiExportAction.java

示例14: make

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
ArrayList<File> make(LoggedInInfo loggedInInfo, List<String> demographicNos, String tmpDir) throws Exception{
XmlOptions options = new XmlOptions();
options.put( XmlOptions.SAVE_PRETTY_PRINT );
options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );

       HashMap<String,String> suggestedPrefix = new HashMap<String,String>();
       suggestedPrefix.put("cds_dt","cdsd");
       options.setSaveSuggestedPrefixes(suggestedPrefix);

options.setSaveOuter();
       ArrayList<File> files = new ArrayList<File>();

       int count = 0;
       for (String demoNo : demographicNos) {
    OmdCdsDiabetesDocument omdCdsDiabetesDoc = OmdCdsDiabetesDocument.Factory.newInstance();
    OmdCdsDiabetesDocument.OmdCdsDiabetes omdcdsdiabetes = omdCdsDiabetesDoc.addNewOmdCdsDiabetes();

    PatientRecord patientRecord = omdcdsdiabetes.addNewPatientRecord();
    if (!fillPatientRecord(loggedInInfo, patientRecord, demoNo)) continue;


           //export file to temp directory
           try{
               File dir = new File(tmpDir);
               if(!dir.exists()){
                   throw new Exception("Temporary Export Directory (as set in oscar.properties) does not exist!");
               }
               String inFile = "omd_diabetes"+count+"-"+UtilDateUtilities.getToday("yyyy-MM-dd.HH.mm.ss")+".xml";
               count++;
               files.add(new File(dir,inFile));
           }catch(Exception e){
               logger.error("Error", e);
           }
           try {
                   omdCdsDiabetesDoc.save(files.get(files.size()-1), options);
           } catch (IOException ex) {logger.error("Error", ex);
                   throw new Exception("Cannot write .xml file(s) to export directory.\nPlease check directory permissions.");
           }
}
       return files;
   }
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:43,代碼來源:DiabetesExportAction.java

示例15: make

import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
ArrayList<File> make(List<String> demographicNos, String tmpDir) throws Exception{
XmlOptions options = new XmlOptions();
options.put( XmlOptions.SAVE_PRETTY_PRINT );
options.put( XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3 );
options.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );

       HashMap<String,String> suggestedPrefix = new HashMap<String,String>();
       suggestedPrefix.put("cds_dt","cdsd");
       options.setSaveSuggestedPrefixes(suggestedPrefix);

options.setSaveOuter();
       ArrayList<File> files = new ArrayList<File>();

       int count = 0;
       for (String demoNo : demographicNos) {
    OmdCdsDiabetesDocument omdCdsDiabetesDoc = OmdCdsDiabetesDocument.Factory.newInstance();
    OmdCdsDiabetesDocument.OmdCdsDiabetes omdcdsdiabetes = omdCdsDiabetesDoc.addNewOmdCdsDiabetes();

    PatientRecord patientRecord = omdcdsdiabetes.addNewPatientRecord();
    if (!fillPatientRecord(patientRecord, demoNo)) continue;


           //export file to temp directory
           try{
               File dir = new File(tmpDir);
               if(!dir.exists()){
                   throw new Exception("Temporary Export Directory (as set in oscar.properties) does not exist!");
               }
               String inFile = "omd_diabetes"+count+"-"+UtilDateUtilities.getToday("yyyy-MM-dd.HH.mm.ss")+".xml";
               count++;
               files.add(new File(dir,inFile));
           }catch(Exception e){
               logger.error("Error", e);
           }
           try {
                   omdCdsDiabetesDoc.save(files.get(files.size()-1), options);
           } catch (IOException ex) {logger.error("Error", ex);
                   throw new Exception("Cannot write .xml file(s) to export directory.\nPlease check directory permissions.");
           }
}
       return files;
   }
 
開發者ID:oscarservice,項目名稱:oscar-old,代碼行數:43,代碼來源:DiabetesExportAction.java


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