use of org.geotoolkit.sml.xml.v100.Document in project dq-easy-cloud by dq-open-cloud.
the class EcGenerateXmlMybatisBO method updateMybatisXmlData.
/**
* 更新mybatis的xml数据
*
* @throws IOException
* @throws JDOMException
*/
protected void updateMybatisXmlData(File generateFile) throws Exception {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(generateFile);
// 获取根元素
Element rootElement = doc.getRootElement();
// 操作更新的数据
doUpdateMybatisXmlData(rootElement);
doXmlOutputter(doc, generateFile);
}
use of org.geotoolkit.sml.xml.v100.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 = token.build(new File("src/test.xml"));
// Document doc = token.build(new FileInputStream("src/test.xml"));
// Document doc = token.build(new FileReader("src/test.xml"));
// Document doc = token.build(new URL("http://localhost:8080/jdomTest/test.xml"));
Document doc = builder.build(EcSourceCodeRelativePath.RESOURCES + "\\test.xml");
readXmlFile(doc);
// addXmlElement(doc);
// updateXmlElement(doc);
// deleteXmlElement(doc);
}
use of org.geotoolkit.sml.xml.v100.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 = token.build(new File("src/test.xml"));
// Document doc = token.build(new FileInputStream("src/test.xml"));
// Document doc = token.build(new FileReader("src/test.xml"));
// Document doc = token.build(new URL("http://localhost:8080/jdomTest/test.xml"));
Document doc = builder.build(EcSourceCodeRelativePath.RESOURCES + "\\test.xml");
readXmlFile(doc);
// addXmlElement(doc);
// updateXmlElement(doc);
// deleteXmlElement(doc);
}
use of org.geotoolkit.sml.xml.v100.Document in project coprhd-controller by CoprHD.
the class ServiceCatalogBuilder method build.
/**
* Parses xml file to ServiceCatalog with Jdom
*
* @param xmlFile
* The instance of xml file
* @return instance of ServiceCatalog
*/
public static ServiceCatalog build(final File xmlFile) {
String fileName = xmlFile.getName().trim().toLowerCase();
// remove suffix
if (fileName.endsWith(Constants.XML_FILE_SUFFIX)) {
fileName = fileName.substring(0, fileName.length() - Constants.XML_FILE_SUFFIX.length() - 1);
} else {
throw new IllegalArgumentException("API file is not xml format: " + fileName);
}
// filter name
int separatorIndex = fileName.indexOf(Constants.NAME_STRING_SEPARATOR);
if (separatorIndex == -1) {
throw new IllegalArgumentException("API file name should split with " + Constants.NAME_STRING_SEPARATOR + " actually: " + fileName);
}
String serviceName = fileName.substring(0, separatorIndex);
String version = fileName.substring(separatorIndex + 1, fileName.length());
Document document;
try {
document = new SAXBuilder().build(xmlFile);
} catch (Exception ex) {
throw new IllegalArgumentException("Invalid XML file:\n " + xmlFile.getAbsolutePath(), ex);
}
if (document == null) {
return null;
}
// Navigates to resource tag, it's a little tricky here, depends on structure of xml file completely.
List<Element> resourceList = document.getRootElement().getChild(Constants.REST_NODE).getChild(Constants.RESOURCES_NODE).getChildren();
// Navigates to element tag, it's a little tricky here, depends on structure of xml file completely.
List<Element> elementList = document.getRootElement().getChild(Constants.DATA_NODE).getChild(Constants.DATA_SCHEMA_NODE).getChild(Constants.ELEMENTS_NODE).getChildren();
return new ServiceCatalog(parseResource(resourceList), parseElement(elementList), serviceName, version);
}
use of org.geotoolkit.sml.xml.v100.Document in project ddf by codice.
the class KmlDocumentToJtsGeometryConverterTest method setupClass.
@BeforeClass
public static void setupClass() {
InputStream stream = KmlDocumentToJtsGeometryConverterTest.class.getResourceAsStream("/kmlDocument.kml");
Kml kml = Kml.unmarshal(stream);
testKmlDocument = ((Document) kml.getFeature());
}
Aggregations