field = (XMLField) referenceMapping.getFields().get(0);
} else {
field = (XMLField) sdoMapping.getField();
}
TreeObjectBuilder treeObjectBuilder = (TreeObjectBuilder) descriptor.getObjectBuilder();
XPathNode xPathNode = treeObjectBuilder.getRootXPathNode();
XPathFragment xPathFragment = field.getXPathFragment();
while (xPathNode != null && xPathFragment != null) {
if (xPathFragment.isAttribute()) {
if (sdoProperty.isMany() && !sdoProperty.isContainment() && !sdoProperty.getType().isDataType()) {
xPathFragment = null;
break;
}
Map attributeChildrenMap = xPathNode.getAttributeChildrenMap();
if (null == attributeChildrenMap) {
xPathNode = null;
} else {
xPathNode = (XPathNode) attributeChildrenMap.get(xPathFragment);
}
} else if (xPathFragment.nameIsText()) {
xPathNode = xPathNode.getTextNode();
} else {
Map nonAttributeChildrenMap = xPathNode.getNonAttributeChildrenMap();
if (null == nonAttributeChildrenMap) {
xPathNode = null;
} else {
xPathNode = (XPathNode) nonAttributeChildrenMap.get(xPathFragment);
}
}
xPathFragment = xPathFragment.getNextFragment();
if (xPathFragment != null && xPathFragment.nameIsText()) {
if (sdoProperty.isMany() && !sdoProperty.isContainment()) {
xPathFragment = null;
break;
}
}
}
if (null == xPathFragment && xPathNode != null) {
if (xPathNode.getNodeValue().isMappingNodeValue()) {
MappingNodeValue mappingNodeValue = (MappingNodeValue) xPathNode.getNodeValue();
return mappingNodeValue.getMapping();
}
}
throw SDOException.sdoJaxbNoMappingForProperty(sdoProperty.getName(), field.getXPath());
}