use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.
the class SimpleXMLFormatProject method buildXRRowSetModelDescriptor.
public ClassDescriptor buildXRRowSetModelDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.descriptorIsAggregate();
descriptor.setJavaClass(SimpleXMLFormatModel.class);
descriptor.setAlias(DEFAULT_SIMPLE_XML_FORMAT_TAG);
descriptor.setNamespaceResolver(ns);
descriptor.setDefaultRootElement(DEFAULT_SIMPLE_XML_FORMAT_TAG);
XMLSchemaURLReference schemaReference = new XMLSchemaURLReference("");
schemaReference.setSchemaContext("/" + DEFAULT_SIMPLE_XML_FORMAT_TAG);
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaReference);
XMLFragmentCollectionMapping fragMapping = new XMLFragmentCollectionMapping();
fragMapping.setAttributeName("simpleXML");
fragMapping.setXPath(DEFAULT_SIMPLE_XML_TAG);
descriptor.addMapping(fragMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.
the class XMLFragmentCollectionElementProject method addEmployeeDescriptor.
public void addEmployeeDescriptor() {
XMLDescriptor desc = new XMLDescriptor();
desc.setJavaClass(Employee.class);
desc.setDefaultRootElement("employee");
desc.setNamespaceResolver(namespaceResolver);
// setup first-name mapping
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("firstName");
mapping.setXPath("first-name/text()");
desc.addMapping(mapping);
// setup last-name mapping
mapping = new XMLDirectMapping();
mapping.setAttributeName("lastName");
mapping.setXPath("last-name/text()");
desc.addMapping(mapping);
// setup xml-node mapping
XMLFragmentCollectionMapping mapping2 = new XMLFragmentCollectionMapping();
mapping2.setAttributeName("xmlnodes");
mapping2.setXPath("xml-node");
mapping2.useCollectionClass(ArrayList.class);
desc.addMapping(mapping2);
// add the descriptor to the project
this.addDescriptor(desc);
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.
the class QueryOperation method addSimpleXMLFormatModelDescriptor.
protected void addSimpleXMLFormatModelDescriptor(XRServiceAdapter xrService) {
if (isSimpleXMLFormat()) {
Session oxSession = xrService.getOXSession();
XMLDescriptor simpleXMLFormatDescriptor = (XMLDescriptor) oxSession.getProject().getClassDescriptor(SimpleXMLFormatModel.class);
if (simpleXMLFormatDescriptor == null) {
simpleXMLFormatDescriptor = new XMLDescriptor();
simpleXMLFormatDescriptor.setJavaClass(SimpleXMLFormatModel.class);
simpleXMLFormatDescriptor.setAlias(DEFAULT_SIMPLE_XML_FORMAT_TAG);
simpleXMLFormatDescriptor.setDefaultRootElement(DEFAULT_SIMPLE_XML_FORMAT_TAG);
XMLFragmentCollectionMapping xmlTag = new XMLFragmentCollectionMapping();
xmlTag.setAttributeName(SIMPLEXML_STR);
xmlTag.setXPath(DEFAULT_SIMPLE_XML_TAG);
simpleXMLFormatDescriptor.addMapping(xmlTag);
NamespaceResolver nr = new NamespaceResolver();
simpleXMLFormatDescriptor.setNamespaceResolver(nr);
XMLSchemaURLReference schemaReference = new XMLSchemaURLReference(EMPTY_STR);
schemaReference.setSchemaContext(SIMPLEXML_FORMAT_STR);
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
simpleXMLFormatDescriptor.setSchemaReference(schemaReference);
oxSession.getProject().addDescriptor(simpleXMLFormatDescriptor);
((DatabaseSessionImpl) oxSession).initializeDescriptorIfSessionAlive(simpleXMLFormatDescriptor);
xrService.getXMLContext().storeXMLDescriptorByQName(simpleXMLFormatDescriptor);
}
}
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.
the class XMLFragmentCollectionNSProject method addEmployeeDescriptor.
public void addEmployeeDescriptor() {
XMLDescriptor desc = new XMLDescriptor();
desc.setJavaClass(Employee.class);
desc.setDefaultRootElement("employee");
desc.setNamespaceResolver(nsresolver);
// setup first-name mapping
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("firstName");
mapping.setXPath("first-name/text()");
desc.addMapping(mapping);
// setup last-name mapping
mapping = new XMLDirectMapping();
mapping.setAttributeName("lastName");
mapping.setXPath("last-name/text()");
desc.addMapping(mapping);
// setup xml-node mapping
XMLFragmentCollectionMapping mapping2 = new XMLFragmentCollectionMapping();
mapping2.setAttributeName("xmlnodes");
mapping2.setXPath("xml-node");
mapping2.useCollectionClass(ArrayList.class);
desc.addMapping(mapping2);
// add the descriptor to the project
this.addDescriptor(desc);
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.
the class SDOProperty method buildXMLFragmentCollectionMapping.
public XMLFragmentCollectionMapping buildXMLFragmentCollectionMapping(String mappingUri) {
XMLFragmentCollectionMapping mapping = new XMLFragmentCollectionMapping();
mapping.setAttributeName(getName());
mapping.setXPath(getQualifiedXPath(mappingUri, false));
mapping.setAttributeAccessor(new SDOFragmentMappingAttributeAccessor(this, aHelperContext));
return mapping;
}
Aggregations