Search in sources :

Example 86 with Document

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);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 87 with Document

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);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Document(org.jdom2.Document)

Example 88 with Document

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);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Document(org.jdom2.Document)

Example 89 with Document

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);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 90 with Document

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());
}
Also used : InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Document(de.micromata.opengis.kml.v_2_2_0.Document) BeforeClass(org.junit.BeforeClass)

Aggregations

Document (org.jdom2.Document)882 Element (org.jdom2.Element)491 Test (org.junit.Test)320 IOException (java.io.IOException)211 SAXBuilder (org.jdom2.input.SAXBuilder)207 XMLOutputter (org.jdom2.output.XMLOutputter)144 File (java.io.File)131 JDOMException (org.jdom2.JDOMException)120 InputStream (java.io.InputStream)61 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 ArrayList (java.util.ArrayList)52 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Path (java.nio.file.Path)46 HashMap (java.util.HashMap)46 List (java.util.List)36 Attribute (org.jdom2.Attribute)35 Document (com.google.cloud.language.v1.Document)34 MCRObjectID (org.mycore.datamodel.metadata.MCRObjectID)34