Search in sources :

Example 21 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 22 with XMLSchemaClassPathReference

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 23 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 24 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 25 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Aggregations

XMLSchemaClassPathReference (org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)71 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)69 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)52 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)36 QName (javax.xml.namespace.QName)13 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)9 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)9 XMLField (org.eclipse.persistence.oxm.XMLField)8 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)6 XMLSchemaReference (org.eclipse.persistence.oxm.schema.XMLSchemaReference)5 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)4 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)2 XmlValue (jakarta.xml.bind.annotation.XmlValue)1 XMLAnyCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)1 XMLTransformationMapping (org.eclipse.persistence.oxm.mappings.XMLTransformationMapping)1