Search in sources :

Example 1 with XmlNamespaces

use of io.atlasmap.xml.v2.XmlNamespaces in project atlasmap by atlasmap.

the class InstanceInspector method mapNamespace.

private void mapNamespace(Node node) {
    if (xmlDocument.getXmlNamespaces() == null) {
        XmlNamespaces namespaces = new XmlNamespaces();
        xmlDocument.setXmlNamespaces(namespaces);
    }
    XmlNamespace namespace = new XmlNamespace();
    namespace.setAlias(node.getPrefix());
    namespace.setUri(node.getNamespaceURI());
    if (!xmlDocument.getXmlNamespaces().getXmlNamespace().contains(namespace)) {
        xmlDocument.getXmlNamespaces().getXmlNamespace().add(namespace);
    }
}
Also used : XmlNamespace(io.atlasmap.xml.v2.XmlNamespace) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces)

Example 2 with XmlNamespaces

use of io.atlasmap.xml.v2.XmlNamespaces in project atlasmap by atlasmap.

the class SchemaInspector method populateNamespaces.

private void populateNamespaces() {
    for (Entry<String, String> entry : namespaceContext.getNamespaceMap().entrySet()) {
        String prefix = entry.getKey();
        String uri = entry.getValue();
        if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(uri) || AtlasXmlConstants.ATLAS_XML_SCHEMASET_NAMESPACE.equals(uri)) {
            continue;
        }
        if (LOG.isTraceEnabled()) {
            LOG.trace("adding a namespace >>> prefix={}, uri={}", prefix, uri);
        }
        if (xmlDocument.getXmlNamespaces() == null) {
            xmlDocument.setXmlNamespaces(new XmlNamespaces());
        }
        XmlNamespace namespace = new XmlNamespace();
        namespace.setAlias(prefix);
        namespace.setUri(uri);
        xmlDocument.getXmlNamespaces().getXmlNamespace().add(namespace);
    }
}
Also used : XmlNamespace(io.atlasmap.xml.v2.XmlNamespace) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces)

Example 3 with XmlNamespaces

use of io.atlasmap.xml.v2.XmlNamespaces in project atlasmap by atlasmap.

the class XmlModule method processPreTargetExecution.

@Override
public void processPreTargetExecution(AtlasInternalSession session) throws AtlasException {
    XmlNamespaces xmlNs = null;
    String template = null;
    for (DataSource ds : session.getMapping().getDataSource()) {
        if (DataSourceType.TARGET.equals(ds.getDataSourceType()) && ds instanceof XmlDataSource && (ds.getId() == null || ds.getId().equals(getDocId()))) {
            xmlNs = ((XmlDataSource) ds).getXmlNamespaces();
            template = ((XmlDataSource) ds).getTemplate();
        }
    }
    Map<String, String> nsMap = new HashMap<String, String>();
    if (xmlNs != null && xmlNs.getXmlNamespace() != null && !xmlNs.getXmlNamespace().isEmpty()) {
        for (XmlNamespace ns : xmlNs.getXmlNamespace()) {
            nsMap.put(ns.getAlias(), ns.getUri());
        }
    }
    XmlFieldWriter writer = new XmlFieldWriter(nsMap, template);
    session.setFieldWriter(getDocId(), writer);
    if (LOG.isDebugEnabled()) {
        LOG.debug("{}: processPreTargetExcution completed", getDocId());
    }
}
Also used : HashMap(java.util.HashMap) XmlNamespace(io.atlasmap.xml.v2.XmlNamespace) XmlFieldWriter(io.atlasmap.xml.core.XmlFieldWriter) XmlNamespaces(io.atlasmap.xml.v2.XmlNamespaces) DataSource(io.atlasmap.v2.DataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource) XmlDataSource(io.atlasmap.xml.v2.XmlDataSource)

Aggregations

XmlNamespace (io.atlasmap.xml.v2.XmlNamespace)3 XmlNamespaces (io.atlasmap.xml.v2.XmlNamespaces)3 DataSource (io.atlasmap.v2.DataSource)1 XmlFieldWriter (io.atlasmap.xml.core.XmlFieldWriter)1 XmlDataSource (io.atlasmap.xml.v2.XmlDataSource)1 HashMap (java.util.HashMap)1