use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class ChildAndGeneratedPrefixClashProject method getTeamDescriptor.
private XMLDescriptor getTeamDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Team.class);
xmlDescriptor.setDefaultRootElement("aaa:team");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("teamName");
nameMapping.setXPath("ns0:teamName/text()");
xmlDescriptor.addMapping(nameMapping);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/aaa:team");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("aaa", "http://www.example.com/aaa");
nsResolver.put("ns0", "http://www.example.com/teamNS0");
nsResolver.put("ns1", "http://www.example.com/teamNS1");
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class DefaultNamespaceProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Employee.class);
xmlDescriptor.setDefaultRootElement("DEFAULT:employee");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("DEFAULT", "http://www.example.com/EMPLOYEE");
xmlDescriptor.setNamespaceResolver(nsResolver);
// Unqualified attributes are in the null namespace
// rather than the default namespace
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("DEFAULT:personal-info/@id");
xmlDescriptor.addMapping(idMapping);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("DEFAULT:personal-info/DEFAULT:name/text()");
xmlDescriptor.addMapping(nameMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class CustomerNSProject method getPhoneNumberDescriptor.
private XMLDescriptor getPhoneNumberDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(PhoneNumber.class);
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("ns", "urn:customer");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping valueMapping = new XMLDirectMapping();
valueMapping.setAttributeName("value");
valueMapping.setXPath("text()");
xmlDescriptor.addMapping(valueMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class CustomerProject method getAddressDescriptor.
private XMLDescriptor getAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Address.class);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.setDefaultNamespaceURI("urn:customer");
descriptor.setNamespaceResolver(nsResolver);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/address-type");
schemaReference.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaReference);
return descriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class SimpleUnionProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
descriptor.setDefaultRootElement("person");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLDirectMapping ageMapping = new XMLDirectMapping();
ageMapping.setAttributeName("age");
XMLUnionField field = new XMLUnionField("age/text()");
QName qname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
field.setSchemaType(qname);
field.addSchemaType(integerQName);
field.addSchemaType(integerQName);
ageMapping.setField(field);
descriptor.addMapping(ageMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
Aggregations