本文整理匯總了Java中org.apache.xmlbeans.XmlOptions.setSaveSuggestedPrefixes方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlOptions.setSaveSuggestedPrefixes方法的具體用法?Java XmlOptions.setSaveSuggestedPrefixes怎麽用?Java XmlOptions.setSaveSuggestedPrefixes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.xmlbeans.XmlOptions
的用法示例。
在下文中一共展示了XmlOptions.setSaveSuggestedPrefixes方法的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: createMarkDocumentsReceivedV2AttachmentBody
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private byte[] createMarkDocumentsReceivedV2AttachmentBody(Collection<TagasisideType> receivedDocsInfos) {
TagasisideArrayType receivedDocs = TagasisideArrayType.Factory.newInstance();
receivedDocs.setItemArray(receivedDocsInfos.toArray(new TagasisideType[receivedDocsInfos.size()]));
if (log.isTraceEnabled()) {
log.trace("created markDocumentsReceivedV2 attachmentBody: " + receivedDocs);
}
XmlOptions options = new XmlOptions();
options.setCharacterEncoding(DVK_MESSAGE_CHARSET);
{ // When marking documents received, with version 2
// they don't accept that item children, such as dhl_id and fault have nameSpace prefixes set
HashMap<String, String> suggestedPrefixes = new HashMap<String, String>(2);
suggestedPrefixes.put("http://www.riik.ee/schemas/dhl", "");
options.setSaveSuggestedPrefixes(suggestedPrefixes);
options.setSaveNoXmlDecl();
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
receivedDocs.save(bos, options);
String s = new String(bos.toByteArray(), DVK_MESSAGE_CHARSET);
return gzipAndEncodeString(s);
} catch (IOException e) {
throw new RuntimeException("Failed to create markDocumentsReceivedV2 request attachmentBody", e);
}
}
示例5: 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();
}
}
示例6: 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;
}
示例7: 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);
}
示例8: 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;
}
示例9: 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;
}
示例10: 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;
}
示例11: 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);
}
}
示例12: getXmlOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
public static XmlOptions getXmlOptions() {
XmlOptions xmlOptions = new XmlOptions();
//xmlOptions.setUseDefaultNamespace();
HashMap<String, String> ns = new HashMap<String, String>();
//ns.put("urn:mpeg:DASH:schema:MPD:2011", "");
ns.put("urn:mpeg:cenc:2013", "cenc");
ns.put("urn:mpeg:drmtdoday:cenc:2014", "drmtoday");
ns.put("urn:microsoft:playready", "mspr");
xmlOptions.setSaveSuggestedPrefixes(ns);
xmlOptions.setSaveAggressiveNamespaces();
xmlOptions.setUseDefaultNamespace();
xmlOptions.setSavePrettyPrint();
return xmlOptions;
}
示例13: getOptions
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private XmlOptions getOptions() {
HashMap<String, String> map = new HashMap<String, String>();
map.put(NAMESPACE, NAMESPACE_PREFIX);
XmlOptions options = new XmlOptions();
options.setSaveAggressiveNamespaces();
options.setSavePrettyPrint();
options.setSaveSuggestedPrefixes(map);
return options;
}
示例14: saveDocumentImpl
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
@Override
protected void saveDocumentImpl(CdwaliteWrapDocument cdwaliteWrapDocument,
OutputStream out) throws IOException {
XmlOptions xmlOptions = new XmlOptions();
HashMap<String, String> namespaceMap = new HashMap<String, String>();
namespaceMap.put(CDWALITE_NS_URI, CDWALITE_NS_PREFIX);
xmlOptions.setSaveSuggestedPrefixes(namespaceMap);
xmlOptions.setSavePrettyPrint();
xmlOptions.setValidateStrict();
addSchemaLocation(cdwaliteWrapDocument);
cdwaliteWrapDocument.save(out, xmlOptions);
}
示例15: generateXml
import org.apache.xmlbeans.XmlOptions; //導入方法依賴的package包/類
private byte[] generateXml(Integer demographicNo, Integer rourkeFdid, Integer nddsFdid, Integer report18mFdid) {
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(pw, opts, rourkeFdid, nddsFdid, report18mFdid);
pw.close();
if (xmlCreated) return os.toByteArray();
}
catch(Exception e) {
logger.warn("Unable to add record",e);
}
return null;
}