use of io.atlasmap.xml.v2.XmlComplexType in project atlasmap by atlasmap.
the class SchemaInspector method printAttributes.
private void printAttributes(XSComplexType xsComplexType, String rootName, XmlComplexType xmlComplexType) {
Collection<? extends XSAttributeUse> c = xsComplexType.getDeclaredAttributeUses();
for (XSAttributeUse aC : c) {
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
XSAttributeDecl attributeDecl = aC.getDecl();
xmlField.setName(getNameNS(attributeDecl));
if (attributeDecl.getDefaultValue() != null) {
xmlField.setValue(attributeDecl.getDefaultValue().value);
} else if (attributeDecl.getFixedValue() != null) {
xmlField.setValue(attributeDecl.getFixedValue().value);
}
xmlField.setPath(rootName + "/" + "@" + getNameNS(attributeDecl));
FieldType attrType = getFieldType(attributeDecl.getType().getName());
xmlField.setFieldType(attrType);
if (xmlField.getFieldType() == null) {
// check the simple types in the schema....
XSSimpleType simpleType = xsComplexType.getRoot().getSimpleType(xsComplexType.getTargetNamespace(), attributeDecl.getType().getName());
if (simpleType != null) {
FieldType fieldType = getFieldType(simpleType.getBaseType().getName());
xmlField.setFieldType(fieldType);
xmlField.setTypeName(attributeDecl.getType().getName());
if (simpleType.asRestriction() != null) {
mapRestrictions(xmlField, simpleType.asRestriction());
}
} else {
// cannot figure it out....
xmlField.setFieldType(FieldType.UNSUPPORTED);
}
}
xmlComplexType.getXmlFields().getXmlField().add(xmlField);
}
}
use of io.atlasmap.xml.v2.XmlComplexType in project atlasmap by atlasmap.
the class SchemaInspector method getXmlComplexType.
private XmlComplexType getXmlComplexType() {
XmlComplexType rootComplexType = XmlComplexTypeFactory.createXmlComlexField();
rootComplexType.setFieldType(FieldType.COMPLEX);
rootComplexType.setXmlFields(new XmlFields());
return rootComplexType;
}
use of io.atlasmap.xml.v2.XmlComplexType in project atlasmap by atlasmap.
the class InstanceInspector method getXmlComplexType.
private XmlComplexType getXmlComplexType(Node childNode) {
XmlComplexType childComplexType = XmlComplexTypeFactory.createXmlComlexField();
childComplexType.setXmlFields(new XmlFields());
childComplexType.setName(childNode.getNodeName());
StringBuffer stringBuffer = new StringBuffer();
getXmlPath(childNode, stringBuffer);
childComplexType.setPath(stringBuffer.toString());
return childComplexType;
}
use of io.atlasmap.xml.v2.XmlComplexType in project atlasmap by atlasmap.
the class InstanceInspector method mapParentNode.
private void mapParentNode(Node node, XmlComplexType parent) {
if (node.hasChildNodes()) {
NodeList childNodes = node.getChildNodes();
XmlComplexType childParent = getXmlComplexType(node);
StringBuffer stringBuffer = new StringBuffer();
getXmlPath(node, stringBuffer);
if (node.hasAttributes()) {
mapAttributes(node, childParent);
}
for (int i = 0; i < childNodes.getLength(); i++) {
Node e = childNodes.item(i);
if (e.getNodeType() == Node.ELEMENT_NODE) {
// do we have child elements?
NodeList childElements = ((Element) e).getElementsByTagName("*");
if (childElements.getLength() > 0) {
mapParentNode(e, childParent);
} else {
mapNodeToXmlField(e, childParent);
if (e.hasAttributes()) {
mapAttributes(e, childParent);
}
}
}
}
mapCollectionType(childParent, (Element) node);
parent.getXmlFields().getXmlField().add(childParent);
}
}
use of io.atlasmap.xml.v2.XmlComplexType in project atlasmap by atlasmap.
the class InstanceInspector method parseDocument.
private void parseDocument(Node rootNode) {
if (rootNode.getParentNode() != null && rootNode.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
XmlComplexType rootComplexType = getXmlComplexType(rootNode);
xmlDocument.getFields().getField().add(rootComplexType);
mapAttributes(rootNode, rootComplexType);
if (rootNode.hasChildNodes()) {
mapChildNodes(rootNode.getChildNodes(), rootComplexType);
}
}
}
Aggregations