use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class EmployeeProject method getPersonDescriptor.
XMLDescriptor getPersonDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Person.class);
xmlDescriptor.setDefaultRootElement("person");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLField classIndicatorField = new XMLField("@xsi:type");
xmlDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
xmlDescriptor.getInheritancePolicy().addClassIndicator(Employee.class, "employee");
XMLDirectMapping mapping = new XMLDirectMapping();
mapping.setAttributeName("firstname");
mapping.setXPath("firstName/text()");
xmlDescriptor.addMapping(mapping);
XMLDirectMapping mapping2 = new XMLDirectMapping();
mapping2.setAttributeName("lastname");
mapping2.setXPath("lastName/text()");
xmlDescriptor.addMapping(mapping2);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/person");
schemaReference.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ChildAndGeneratedPrefixClashProject method getCompanyDescriptor.
private XMLDescriptor getCompanyDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Company.class);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("companyName");
nameMapping.setXPath("aaa:companyname/text()");
xmlDescriptor.addMapping(nameMapping);
// XMLCompositeCollectionMapping departmentsMapping = new XMLCompositeCollectionMapping();
XMLAnyCollectionMapping departmentsMapping = new XMLAnyCollectionMapping();
departmentsMapping.setAttributeName("departments");
departmentsMapping.setXPath("aaa:departments");
departmentsMapping.setUseXMLRoot(true);
// departmentsMapping.setReferenceClass(Department.class);
xmlDescriptor.addMapping(departmentsMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("aaa", "http://www.example.com/aaa");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/aaa:company");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ChildAndGeneratedPrefixClashProject method getDepartmentDescriptor.
private XMLDescriptor getDepartmentDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Department.class);
xmlDescriptor.setDefaultRootElement("aaa:department");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("deptName");
nameMapping.setXPath("aaa:deptName/text()");
xmlDescriptor.addMapping(nameMapping);
// XMLAnyCollectionMapping teamsMapping = new XMLAnyCollectionMapping();
XMLCompositeCollectionMapping teamsMapping = new XMLCompositeCollectionMapping();
teamsMapping.setAttributeName("teams");
teamsMapping.setXPath("aaa:teams/aaa:team");
teamsMapping.setReferenceClass(Team.class);
// steamsMapping.setUseXMLRoot(true);
xmlDescriptor.addMapping(teamsMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("aaa", "http://www.example.com/aaa");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/aaa:dept");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ExtraNamespacesBug6004272Project method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Employee.class);
xmlDescriptor.setDefaultRootElement("ns4:employee");
XMLField classIndicatorField = new XMLField("@xsi:type");
xmlDescriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
xmlDescriptor.getInheritancePolicy().addClassIndicator(Employee.class, "ns4:emp-type");
xmlDescriptor.getInheritancePolicy().addClassIndicator(Manager.class, "ns2:manager-type");
xmlDescriptor.getInheritancePolicy().setShouldReadSubclasses(true);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("ns4:personal-info/@ns4:id");
xmlDescriptor.addMapping(idMapping);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("ns4:personal-info/ns4:name/text()");
xmlDescriptor.addMapping(nameMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns4", "http://www.example.com/ns4");
nsResolver.put("ns2", "http://www.example.com/ns2");
nsResolver.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/ns4:emp-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class ExtraNamespacesBug6004272Project method getProjectDescriptor.
private XMLDescriptor getProjectDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(org.eclipse.persistence.testing.oxm.mappings.namespaces.Project.class);
xmlDescriptor.setDefaultRootElement("ns6Other:project");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("ns6Other:name/text()");
xmlDescriptor.addMapping(nameMapping);
XMLDirectMapping descMapping = new XMLDirectMapping();
descMapping.setAttributeName("description");
descMapping.setXPath("ns6Other:description/text()");
xmlDescriptor.addMapping(descMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns6Other", "http://www.example.com/ns6");
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/ns6Other:project-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
Aggregations