use of org.eclipse.persistence.sdo.helper.metadata.NamespaceURITransformer in project eclipselink by eclipse-ee4j.
the class SDOProperty method buildXMLTransformationMapping.
private DatabaseMapping buildXMLTransformationMapping(String mappingUri) {
XMLTransformationMapping mapping = new XMLTransformationMapping();
mapping.setAttributeName(getName());
String xpath = getQualifiedXPath(mappingUri, true);
String xpathMinusText;
int indexOfTextXPath = xpath.lastIndexOf("/text()");
if (indexOfTextXPath < 0) {
xpathMinusText = xpath;
} else {
xpathMinusText = xpath.substring(0, indexOfTextXPath);
}
QNameTransformer transformer = new QNameTransformer(xpath);
mapping.setAttributeTransformer(transformer);
mapping.addFieldTransformer(xpath, transformer);
NamespaceResolver nsr = new NamespaceResolver();
nsr.put(javax.xml.XMLConstants.XMLNS_ATTRIBUTE, javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
XMLField field = new XMLField();
field.setNamespaceResolver(nsr);
field.setXPath(xpathMinusText + "/@" + javax.xml.XMLConstants.XMLNS_ATTRIBUTE + ":" + QNameTransformer.QNAME_NAMESPACE_PREFIX);
mapping.addFieldTransformer(field, new NamespaceURITransformer());
return mapping;
}
use of org.eclipse.persistence.sdo.helper.metadata.NamespaceURITransformer in project eclipselink by eclipse-ee4j.
the class SDOWrapperType method initializeDescriptor.
private void initializeDescriptor(XMLDescriptor aDescriptor, QName aQName, Type aPropertyType, SDOProperty aValueProperty) {
aDescriptor.setNamespaceResolver(null);
SDOMethodAttributeAccessor accessor = null;
accessor = new SDOMethodAttributeAccessor(aValueProperty);
if (XMLConstants.QNAME_QNAME.equals(aQName)) {
XMLTransformationMapping mapping = new XMLTransformationMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
QNameTransformer transformer = new QNameTransformer("text()");
mapping.setAttributeTransformer(transformer);
mapping.addFieldTransformer(XPATH, transformer);
NamespaceResolver nsr = new NamespaceResolver();
nsr.setDefaultNamespaceURI(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
XMLField field = new XMLField();
field.setNamespaceResolver(nsr);
field.setXPath("@" + javax.xml.XMLConstants.XMLNS_ATTRIBUTE);
mapping.addFieldTransformer(field, new NamespaceURITransformer());
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
} else {
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName(ATTRIBUTE_NAME);
mapping.setXPath(XPATH);
mapping.setAttributeClassification(aPropertyType.getInstanceClass());
((XMLField) mapping.getField()).setSchemaType(aQName);
mapping.setAttributeAccessor(accessor);
aDescriptor.addMapping(mapping);
}
aDescriptor.setIsWrapper(true);
}
Aggregations