use of org.eclipse.persistence.oxm.mappings.XMLFragmentMapping in project eclipselink by eclipse-ee4j.
the class SDOProperty method buildXMLFragmentMapping.
public XMLFragmentMapping buildXMLFragmentMapping(String uri) {
XMLFragmentMapping mapping = new XMLFragmentMapping();
mapping.setAttributeName(getName());
mapping.setXPath(getQualifiedXPath(uri, false));
mapping.setAttributeAccessor(new SDOFragmentMappingAttributeAccessor(this, aHelperContext));
return mapping;
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentMapping in project eclipselink by eclipse-ee4j.
the class SelfProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("bar:employee");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("bar", "urn:example");
descriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("bar:first-name/text()");
firstNameMapping.setIsReadOnly(true);
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("bar:last-name/text()");
lastNameMapping.setIsReadOnly(true);
descriptor.addMapping(lastNameMapping);
XMLFragmentMapping nodeMapping = new XMLFragmentMapping();
nodeMapping.setAttributeName("xmlNode");
nodeMapping.setXPath(".");
descriptor.addMapping(nodeMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentMapping in project eclipselink by eclipse-ee4j.
the class XMLFragmentElementProject method addEmployeeDescriptor.
public void addEmployeeDescriptor() {
XMLDescriptor desc = new XMLDescriptor();
desc.setJavaClass(Employee.class);
desc.setDefaultRootElement("employee");
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("firstName");
mapping.setXPath("first-name/text()");
desc.addMapping(mapping);
mapping = new XMLDirectMapping();
mapping.setAttributeName("lastName");
mapping.setXPath("last-name/text()");
desc.addMapping(mapping);
XMLFragmentMapping mapping2 = new XMLFragmentMapping();
mapping2.setAttributeName("xmlNode");
mapping2.setXPath("xml-node");
desc.addMapping(mapping2);
// desc.setShouldPreserveDocument(true);
this.addDescriptor(desc);
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentMapping in project eclipselink by eclipse-ee4j.
the class XMLFragmentTextNodeProject method addEmployeeDescriptor.
public void addEmployeeDescriptor() {
XMLDescriptor desc = new XMLDescriptor();
desc.setJavaClass(Employee.class);
desc.setDefaultRootElement("employee");
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("firstName");
mapping.setXPath("first-name/text()");
desc.addMapping(mapping);
mapping = new XMLDirectMapping();
mapping.setAttributeName("lastName");
mapping.setXPath("last-name/text()");
desc.addMapping(mapping);
XMLFragmentMapping mapping2 = new XMLFragmentMapping();
mapping2.setAttributeName("xmlNode");
mapping2.setXPath("xml-node/text()");
desc.addMapping(mapping2);
// desc.setShouldPreserveDocument(true);
this.addDescriptor(desc);
}
use of org.eclipse.persistence.oxm.mappings.XMLFragmentMapping in project eclipselink by eclipse-ee4j.
the class XMLFragmentNSTestCases method testObjectToXMLStringWriterPrefixedChild.
/**
* Test WriterRecord - prefixed child nodes
*/
public void testObjectToXMLStringWriterPrefixedChild() throws Exception {
NamespaceResolver nsresolver = new NamespaceResolver();
nsresolver.put("ns1", "http://www.example.com/test-uri");
XMLFragmentMapping mapping = new XMLFragmentMapping();
mapping.setAttributeName("xmlNode");
mapping.setXPath("ns1:xml-node");
setProject(new XMLFragmentNSProject(nsresolver, mapping));
StringWriter writer = new StringWriter();
xmlMarshaller.marshal(getWriteControlObjectNS(XML_SUB_ELEMENT_PFX_CHILD, "http://www.example.com/test-uri"), writer);
StringReader reader = new StringReader(writer.toString());
InputSource inputSource = new InputSource(reader);
Document testDocument = parser.parse(inputSource);
writer.close();
reader.close();
objectToXMLDocumentTest(testDocument, XML_RESOURCE_PFX_CHILD, "testObjectToXMLStringWriterPrefixedChild");
}
Aggregations