Search in sources :

Example 1 with NamespaceURITransformer

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) QNameTransformer(org.eclipse.persistence.sdo.helper.metadata.QNameTransformer) XMLTransformationMapping(org.eclipse.persistence.oxm.mappings.XMLTransformationMapping) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) NamespaceURITransformer(org.eclipse.persistence.sdo.helper.metadata.NamespaceURITransformer)

Example 2 with NamespaceURITransformer

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);
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QNameTransformer(org.eclipse.persistence.sdo.helper.metadata.QNameTransformer) XMLTransformationMapping(org.eclipse.persistence.oxm.mappings.XMLTransformationMapping) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) SDOMethodAttributeAccessor(org.eclipse.persistence.sdo.helper.SDOMethodAttributeAccessor) NamespaceURITransformer(org.eclipse.persistence.sdo.helper.metadata.NamespaceURITransformer)

Aggregations

NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)2 XMLField (org.eclipse.persistence.oxm.XMLField)2 XMLTransformationMapping (org.eclipse.persistence.oxm.mappings.XMLTransformationMapping)2 NamespaceURITransformer (org.eclipse.persistence.sdo.helper.metadata.NamespaceURITransformer)2 QNameTransformer (org.eclipse.persistence.sdo.helper.metadata.QNameTransformer)2 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)1 SDOMethodAttributeAccessor (org.eclipse.persistence.sdo.helper.SDOMethodAttributeAccessor)1