Search in sources :

Example 51 with XMLSchemaClassPathReference

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

Example 52 with XMLSchemaClassPathReference

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

Example 53 with XMLSchemaClassPathReference

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

Example 54 with XMLSchemaClassPathReference

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

Example 55 with XMLSchemaClassPathReference

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;
}
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