use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class RootElementProject method getSportsCarDescriptor.
private XMLDescriptor getSportsCarDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(SportsCar.class);
// For this test each descriptor in the inheritance hierarchy must have
// a different default root element.
xmlDescriptor.setDefaultRootElement("sports-car");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("xsi", javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
xmlDescriptor.setNamespaceResolver(nsResolver);
xmlDescriptor.getInheritancePolicy().setParentClass(Car.class);
XMLSchemaReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/sports-car");
xmlDescriptor.setSchemaReference(schemaReference);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class RootElementProject method getCarDescriptor.
private XMLDescriptor getCarDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Car.class);
// For this test each descriptor in the inheritance hierarchy must have
// a different default root element.
xmlDescriptor.setDefaultRootElement("car");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("xsi", javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
xmlDescriptor.setNamespaceResolver(nsResolver);
xmlDescriptor.getInheritancePolicy().setParentClass(Vehicle.class);
XMLSchemaReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/car");
xmlDescriptor.setSchemaReference(schemaReference);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class RootElementProject method getVehicleDescriptor.
private XMLDescriptor getVehicleDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Vehicle.class);
// For this test each descriptor in the inheritance hierarchy must have
// a different default root element.
xmlDescriptor.setDefaultRootElement("vehicle");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("xsi", javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
xmlDescriptor.setNamespaceResolver(nsResolver);
xmlDescriptor.getInheritancePolicy().setClassIndicatorFieldName("@xsi:type");
xmlDescriptor.getInheritancePolicy().addClassIndicator(Vehicle.class, "vehicle");
xmlDescriptor.getInheritancePolicy().addClassIndicator(Car.class, "car");
xmlDescriptor.getInheritancePolicy().addClassIndicator(SportsCar.class, "sports-car");
XMLSchemaReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/vehicle");
xmlDescriptor.setSchemaReference(schemaReference);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class CompositeCollectionWithGroupingElementIdentifiedByNamespaceProject 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_PREFIX + ":street/text()");
descriptor.addMapping(streetMapping);
XMLDirectMapping cityMapping = new XMLDirectMapping();
cityMapping.setAttributeName("city");
cityMapping.setXPath(MAILING_PREFIX + ":city/text()");
descriptor.addMapping(cityMapping);
XMLDirectMapping provinceMapping = new XMLDirectMapping();
provinceMapping.setAttributeName("province");
provinceMapping.setXPath(MAILING_PREFIX + ":province/text()");
descriptor.addMapping(provinceMapping);
XMLDirectMapping postalCodeMapping = new XMLDirectMapping();
postalCodeMapping.setAttributeName("postalCode");
postalCodeMapping.setXPath(MAILING_PREFIX + ":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 CompositeObjectIdentifiedByNameProject method getMailingAddressDescriptor.
private XMLDescriptor getMailingAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(MailingAddress.class);
XMLDirectMapping streetMapping = new XMLDirectMapping();
streetMapping.setAttributeName("street");
streetMapping.setXPath("street/text()");
descriptor.addMapping(streetMapping);
XMLDirectMapping cityMapping = new XMLDirectMapping();
cityMapping.setAttributeName("city");
cityMapping.setXPath("city/text()");
descriptor.addMapping(cityMapping);
XMLDirectMapping provinceMapping = new XMLDirectMapping();
provinceMapping.setAttributeName("province");
provinceMapping.setXPath("province/text()");
descriptor.addMapping(provinceMapping);
XMLDirectMapping postalCodeMapping = new XMLDirectMapping();
postalCodeMapping.setAttributeName("postalCode");
postalCodeMapping.setXPath("postal-code/text()");
descriptor.addMapping(postalCodeMapping);
XMLSchemaClassPathReference schemaRef = new XMLSchemaClassPathReference();
schemaRef.setSchemaContext("/mailingAddressType");
schemaRef.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaRef);
return descriptor;
}
Aggregations