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);
}
}
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);
}
}
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());
}
}
Aggregations