本文整理匯總了Java中org.apache.xmlbeans.XmlOptions.put方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlOptions.put方法的具體用法?Java XmlOptions.put怎麽用?Java XmlOptions.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.xmlbeans.XmlOptions
的用法示例。
在下文中一共展示了XmlOptions.put方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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;
}
示例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;
}
示例4: getOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/**
*
* @return
*/
private XmlOptions getOptions()
{
XmlOptions options = new XmlOptions();
if (lib.ignoreComments)
{
options.put(XmlOptions.LOAD_STRIP_COMMENTS);
}
if (lib.ignoreProcessingInstructions)
{
options.put(XmlOptions.LOAD_STRIP_PROCINSTS);
}
if (lib.ignoreWhitespace)
{
options.put(XmlOptions.LOAD_STRIP_WHITESPACE);
}
if (lib.prettyPrinting)
{
options.put(XmlOptions.SAVE_PRETTY_PRINT, null);
options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, new Integer(lib.prettyIndent));
}
return options;
}
示例5: 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;
}
示例6: 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);
}
}
示例7: 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;
}
示例8: createInstanceForSchemaType
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
/***
* 處理全局的schematype數據內容
* @param sType 當前schema節點
* @return 解析出來的xml表達式
*/
public String createInstanceForSchemaType(SchemaType sType, boolean isSaveJson,String fileName)
{
XmlObject xmlobject = XmlObject.Factory.newInstance();
XmlCursor cursor = xmlobject.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
_soapEnc = false;
//RestfulApiSchemaManager restful = new RestfulApiSchemaManager(false);
setViewAttrib(isSaveJson);
Map<String, String> mapValues = new LinkedHashMap<String, String>();
createSampleForType(sType, cursor, mapValues);
// 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.
XmlOptions options = new XmlOptions();
options.put(XmlOptions.SAVE_PRETTY_PRINT);
options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 2);
options.put(XmlOptions.SAVE_USE_DEFAULT_NAMESPACE);
String result = xmlobject.xmlText(options);
//System.out.println(result);
// get current xml object
navigatingXML(xmlobject,fileName);
// System.out.println(getRestApiManager().getAllRestfulApi());
return result;
}
示例9: buildMetkaDDIExportXmlOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private static final XmlOptions buildMetkaDDIExportXmlOptions()
{
XmlOptions xmlOptions = new XmlOptions();
xmlOptions.setSaveCDataEntityCountThreshold(100);
xmlOptions.setSaveCDataLengthThreshold(100);
xmlOptions.put( XmlOptions.SAVE_INNER );
xmlOptions.put( XmlOptions.SAVE_PRETTY_PRINT );
xmlOptions.put( XmlOptions.SAVE_AGGRESSIVE_NAMESPACES );
xmlOptions.put( XmlOptions.SAVE_USE_DEFAULT_NAMESPACE );
return xmlOptions;
}
示例10: 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;
}
示例11: 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;
}
示例12: 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;
}