Search in sources :

Example 81 with Document

use of io.atlasmap.v2.Document in project aws-doc-sdk-examples by awsdocs.

the class DynamoDBService method injectETLData.

public void injectETLData(String myDom) throws JDOMException, IOException {
    SAXBuilder builder = new SAXBuilder();
    Document jdomDocument = builder.build(new InputSource(new StringReader(myDom)));
    org.jdom2.Element root = ((org.jdom2.Document) jdomDocument).getRootElement();
    PopData pop = new PopData();
    List<org.jdom2.Element> items = root.getChildren("Item");
    for (org.jdom2.Element element : items) {
        pop.setName(element.getChildText("Name"));
        pop.setCode(element.getChildText("Code"));
        pop.set2010(element.getChildText("Date2010"));
        pop.set2011(element.getChildText("Date2011"));
        pop.set2012(element.getChildText("Date2012"));
        pop.set2013(element.getChildText("Date2013"));
        pop.set2014(element.getChildText("Date2014"));
        pop.set2015(element.getChildText("Date2015"));
        pop.set2016(element.getChildText("Date2016"));
        pop.set2017(element.getChildText("Date2017"));
        pop.set2018(element.getChildText("Date2018"));
        pop.set2019(element.getChildText("Date2019"));
        setItem(pop);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) InputSource(org.xml.sax.InputSource) StringReader(java.io.StringReader) Document(org.jdom2.Document)

Example 82 with Document

use of io.atlasmap.v2.Document in project jena by apache.

the class GMLReader method extract.

public static GMLReader extract(String gmlText) throws JDOMException, IOException {
    if (gmlText.isEmpty()) {
        gmlText = EMPTY_GML_TEXT;
    }
    SAXBuilder jdomBuilder = newSAXBuilder();
    InputStream stream = new ByteArrayInputStream(gmlText.getBytes(StandardCharsets.UTF_8));
    Document xmlDoc = jdomBuilder.build(stream);
    Element gmlElement = xmlDoc.getRootElement();
    return new GMLReader(gmlElement);
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 83 with Document

use of io.atlasmap.v2.Document in project gocd by gocd.

the class GoConfigMigration method getCurrentSchemaVersion.

private int getCurrentSchemaVersion(String content) {
    try {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new ByteArrayInputStream(content.getBytes()));
        Element root = document.getRootElement();
        String currentVersion = root.getAttributeValue(schemaVersion) == null ? "0" : root.getAttributeValue(schemaVersion);
        return Integer.parseInt(currentVersion);
    } catch (Exception e) {
        throw bomb(e);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) XmlUtils.buildXmlDocument(com.thoughtworks.go.util.XmlUtils.buildXmlDocument) Document(org.jdom2.Document) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException)

Example 84 with Document

use of io.atlasmap.v2.Document in project gocd by gocd.

the class GoConfigMigrationIntegrationTest method shouldRemoveAllLuauConfigurationFromConfig.

@Test
public void shouldRemoveAllLuauConfigurationFromConfig() throws Exception {
    String configString = "<cruise schemaVersion='66'>" + "<server siteUrl='https://hostname'>" + "<security>" + "      <luau url='https://luau.url.com' clientKey='0d010cf97ec505ee3788a9b5b8cf71d482c394ae88d32f0333' authState='authorized' />" + "      <ldap uri='ldap' managerDn='managerDn' encryptedManagerPassword='+XhtUNvVAxJdHGF4qQGnWw==' searchFilter='(sAMAccountName={0})'>" + "        <bases>" + "          <base value='ou=Enterprise,ou=Principal,dc=corporate,dc=thoughtworks,dc=com' />" + "        </bases>" + "      </ldap>" + "      <roles>" + "         <role name='luau-role'><groups><luauGroup>luau-group</luauGroup></groups></role>" + "         <role name='ldap-role'><users><user>some-user</user></users></role>" + "</roles>" + "</security>" + "</server>" + "</cruise>";
    String migratedContent = migrateXmlString(configString, 66);
    Document document = new SAXBuilder().build(new StringReader(migratedContent));
    assertThat(document.getDescendants(new ElementFilter("luau")).hasNext()).isFalse();
    assertThat(document.getDescendants(new ElementFilter("groups")).hasNext()).isFalse();
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) ElementFilter(org.jdom2.filter.ElementFilter) StringReader(java.io.StringReader) Document(org.jdom2.Document) Test(org.junit.jupiter.api.Test)

Example 85 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRFileNodeServlet method sendDirectory.

/**
 * Sends the contents of an MCRDirectory as XML data to the client
 * @throws SAXException
 * @throws TransformerException
 */
private MCRContent sendDirectory(HttpServletRequest request, HttpServletResponse response, MCRPath mcrPath) throws IOException, TransformerException, SAXException {
    Document directoryXML = MCRPathXML.getDirectoryXML(mcrPath);
    MCRJDOMContent source = new MCRJDOMContent(directoryXML);
    source.setLastModified(Files.getLastModifiedTime(mcrPath).toMillis());
    String fileName = mcrPath.getNameCount() == 0 ? mcrPath.getOwner() : mcrPath.getFileName().toString();
    source.setName(fileName);
    return getLayoutService().getTransformedContent(request, response, source);
}
Also used : MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document)

Aggregations

Document (org.jdom2.Document)403 Element (org.jdom2.Element)248 Test (org.junit.Test)111 SAXBuilder (org.jdom2.input.SAXBuilder)95 IOException (java.io.IOException)74 File (java.io.File)58 XMLOutputter (org.jdom2.output.XMLOutputter)55 JDOMException (org.jdom2.JDOMException)44 Field (io.atlasmap.v2.Field)40 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)34 ArrayList (java.util.ArrayList)30 Test (org.junit.jupiter.api.Test)27 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)25 DocType (org.jdom2.DocType)24 InputStream (java.io.InputStream)23 JsonField (io.atlasmap.json.v2.JsonField)22 MCRContent (org.mycore.common.content.MCRContent)22 Document (com.google.cloud.language.v1.Document)21 HashMap (java.util.HashMap)21 MCRException (org.mycore.common.MCRException)21