use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class AnyTypeProject method getAddressDescriptor.
public XMLDescriptor getAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Address.class);
descriptor.setDefaultRootElement("contact-method");
descriptor.setDefaultRootElementType(new QName("http://www.example.com/toplink-oxm", "contact-method-type"));
descriptor.setNamespaceResolver(namespaceResolver);
descriptor.getInheritancePolicy().setParentClass(ContactMethod.class);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/oxm:address-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(ref);
XMLDirectMapping streetMapping = new XMLDirectMapping();
streetMapping.setAttributeName("street");
streetMapping.setXPath("street/text()");
descriptor.addMapping(streetMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class AnyCollectionTypeProject method getContactMethodDescriptor.
public XMLDescriptor getContactMethodDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(ContactMethod.class);
descriptor.setDefaultRootElement("contact-method");
descriptor.setDefaultRootElementType(new QName("contact-method-type"));
descriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/contact-method-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(ref);
XMLField classIndicatorField = new XMLField("@xsi:type");
descriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
descriptor.getInheritancePolicy().addClassIndicator(ContactMethod.class, "contact-method-type");
descriptor.getInheritancePolicy().addClassIndicator(Address.class, "address-type");
descriptor.getInheritancePolicy().addClassIndicator(CanadianAddress.class, "canadian-address-type");
descriptor.getInheritancePolicy().setShouldReadSubclasses(true);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("id/text()");
descriptor.addMapping(idMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class CompositeObjectIdentifiedByNamespaceProject method getEmailAddressDescriptor.
private XMLDescriptor getEmailAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(EmailAddress.class);
descriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping userIDMapping = new XMLDirectMapping();
userIDMapping.setAttributeName("userID");
userIDMapping.setXPath("email:user-id/text()");
descriptor.addMapping(userIDMapping);
XMLDirectMapping domainMapping = new XMLDirectMapping();
domainMapping.setAttributeName("domain");
domainMapping.setXPath("email:domain/text()");
descriptor.addMapping(domainMapping);
XMLSchemaClassPathReference schemaRef = new XMLSchemaClassPathReference();
schemaRef.setSchemaContext("/email:addressType");
schemaRef.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaRef);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class CompositeObjectIdentifiedByNamespaceProject method getMailingAddressDescriptor.
private XMLDescriptor getMailingAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(MailingAddress.class);
descriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping streetMapping = new XMLDirectMapping();
streetMapping.setAttributeName("street");
streetMapping.setXPath("mailing:street/text()");
descriptor.addMapping(streetMapping);
XMLDirectMapping cityMapping = new XMLDirectMapping();
cityMapping.setAttributeName("city");
cityMapping.setXPath("mailing:city/text()");
descriptor.addMapping(cityMapping);
XMLDirectMapping provinceMapping = new XMLDirectMapping();
provinceMapping.setAttributeName("province");
provinceMapping.setXPath("mailing:province/text()");
descriptor.addMapping(provinceMapping);
XMLDirectMapping postalCodeMapping = new XMLDirectMapping();
postalCodeMapping.setAttributeName("postalCode");
postalCodeMapping.setXPath("mailing:postal-code/text()");
descriptor.addMapping(postalCodeMapping);
XMLSchemaClassPathReference schemaRef = new XMLSchemaClassPathReference();
schemaRef.setSchemaContext("/mailing:addressType");
schemaRef.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaRef);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference 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;
}
Aggregations