use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project dq-easy-cloud by dq-open-cloud.
the class DqXMLUtils method getMapFromInputStream.
/**
* <p>
* 将xml流中的信息放入map中
* </p>
*
* @param inputStream
* : InputStream : xml输入流
* @param paramsMap
* : Map<String, Object> : xml结果容器
* @return Map<String, Object>
* @throws IOException
* @author daiqi 创建时间 2018年2月23日 下午12:49:06
*/
public static Map<String, Object> getMapFromInputStream(InputStream inputStream, Map<String, Object> paramsMap) throws IOException {
if (null == paramsMap) {
paramsMap = new HashMap<>();
}
SAXBuilder builder = new SAXBuilder();
try {
Document doc = builder.build(inputStream);
Element root = doc.getRootElement();
List<Element> list = root.getChildren();
Iterator<Element> it = list.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
String k = e.getName();
Object v = DqStringUtils.EMPTY;
List<Element> children = e.getChildren();
if (children.isEmpty()) {
v = e.getTextNormalize();
} else {
v = getChildren(children);
}
paramsMap.put(k, v);
}
} catch (JDOMException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return paramsMap;
}
use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project dq-easy-cloud by dq-open-cloud.
the class XmlUtilsTest method main.
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(new File("src/test.xml"));
// Document doc = builder.build(new FileInputStream("src/test.xml"));
// Document doc = builder.build(new FileReader("src/test.xml"));
// Document doc = builder.build(new URL("http://localhost:8080/jdomTest/test.xml"));
Document doc = builder.build(DqSourceCodeRelativePath.RESOURCES + "\\test.xml");
readXmlFile(doc);
// addXmlElement(doc);
// updateXmlElement(doc);
// deleteXmlElement(doc);
}
use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project archi by archimatetool.
the class JDOMUtilsTests method testWrite2XMLFile.
@Test
public void testWrite2XMLFile() throws Exception {
File tmpFile = TestUtils.createTempFile(".xml");
Document doc = createDocument();
JDOMUtils.write2XMLFile(doc, tmpFile);
assertTrue(tmpFile.exists());
}
use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project archi by archimatetool.
the class JDOMUtilsTests method testReadXMLFile_File.
@Test
public void testReadXMLFile_File() throws Exception {
File file = new File(TESTDATA_FOLDER, "imsmanifest.xml");
Document doc = JDOMUtils.readXMLFile(file);
assertNotNull(doc);
assertTrue(doc.hasRootElement());
}
use of iso.std.iso._20022.tech.xsd.pain_001_001.Document in project archi by archimatetool.
the class SaveCanvasAsTemplateWizard method createManifest.
private String createManifest() throws IOException {
Document doc = new Document();
Element root = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_MANIFEST);
doc.setRootElement(root);
// Type
root.setAttribute(ITemplateXMLTags.XML_TEMPLATE_ATTRIBUTE_TYPE, CanvasModelTemplate.XML_CANVAS_TEMPLATE_ATTRIBUTE_TYPE_MODEL);
// Timestamp
root.setAttribute(ITemplateXMLTags.XML_TEMPLATE_ATTRIBUTE_TIMESTAMP, Long.toString(System.currentTimeMillis()));
// Name
Element elementName = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_NAME);
elementName.setText(fTemplateName);
root.addContent(elementName);
// Description
Element elementDescription = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_DESCRIPTION);
elementDescription.setText(fTemplateDescription);
root.addContent(elementDescription);
// Thumbnail
if (fIncludeThumbnail) {
// $NON-NLS-1$
String keyThumb = TemplateManager.ZIP_ENTRY_THUMBNAILS + "1.png";
Element elementKeyThumb = new Element(ITemplateXMLTags.XML_TEMPLATE_ELEMENT_KEY_THUMBNAIL);
elementKeyThumb.setText(keyThumb);
root.addContent(elementKeyThumb);
}
return JDOMUtils.write2XMLString(doc);
}
Aggregations