use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class ExtraNamespacesBug6004272Project method getTeamDescriptor.
private XMLDescriptor getTeamDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Team.class);
xmlDescriptor.setDefaultRootElement("ns4:team");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("teamName");
nameMapping.setXPath("ns4:teamName/text()");
xmlDescriptor.addMapping(nameMapping);
XMLAnyObjectMapping teamLeaderMapping = new XMLAnyObjectMapping();
teamLeaderMapping.setAttributeName("teamLeader");
teamLeaderMapping.setXPath("ns5:leader");
xmlDescriptor.addMapping(teamLeaderMapping);
XMLCompositeCollectionMapping empsMapping = new XMLCompositeCollectionMapping();
empsMapping.setAttributeName("employees");
empsMapping.setXPath("ns6:emp");
// no reference class
xmlDescriptor.addMapping(empsMapping);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/ns4:team");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(ref);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns4", "http://www.example.com/ns4");
nsResolver.put("ns5", "http://www.example.com/ns5");
nsResolver.put("ns6", "http://www.example.com/ns6");
// nsResolver.put("ns2", "http://www.example.com/ns2");
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class ExtraNamespacesBug6004272Project method getCompanyDescriptor.
private XMLDescriptor getCompanyDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Company.class);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("companyName");
nameMapping.setXPath("ns2:companyname/text()");
xmlDescriptor.addMapping(nameMapping);
XMLCompositeObjectMapping managerMapping = new XMLCompositeObjectMapping();
managerMapping.setAttributeName("manager");
managerMapping.setXPath("ns2:manager");
managerMapping.setReferenceClass(Manager.class);
// XMLField xmlFld = (XMLField) managerMapping.getField();
// xmlFld.setLeafElementType(new QName("http://www.example.com/ns2","manager-type"));
xmlDescriptor.addMapping(managerMapping);
XMLCompositeCollectionMapping departmentsMapping = new XMLCompositeCollectionMapping();
departmentsMapping.setAttributeName("departments");
departmentsMapping.setXPath("ns2:departments/ns2:dept");
departmentsMapping.setReferenceClass(Department.class);
xmlDescriptor.addMapping(departmentsMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
// keep in resolver
nsResolver.put("ns1", "http://www.example.com/rootns");
nsResolver.put("ns2", "http://www.example.com/ns2");
nsResolver.put("aaa", "http://www.example.com/aaa");
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class GloballyDefinedNodesProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Employee.class);
xmlDescriptor.setDefaultRootElement("ns:employee");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns", "http://www.example.com/EMPLOYEE");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("ns:personal-info/@ns:id");
xmlDescriptor.addMapping(idMapping);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("ns:personal-info/ns:name/text()");
xmlDescriptor.addMapping(nameMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class LocallyDefinedNodesProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Employee.class);
xmlDescriptor.setDefaultRootElement("ns:employee");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns", "http://www.example.com/EMPLOYEE");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("ns:personal-info/@id");
xmlDescriptor.addMapping(idMapping);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("ns:personal-info/name/text()");
xmlDescriptor.addMapping(nameMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class ChildAndGeneratedPrefixClashProject method getRootDescriptor.
private XMLDescriptor getRootDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Root.class);
xmlDescriptor.setDefaultRootElement("aaa:root");
// XMLCompositeCollectionMapping companiesMapping = new XMLCompositeCollectionMapping();
XMLAnyCollectionMapping companiesMapping = new XMLAnyCollectionMapping();
companiesMapping.setAttributeName("companies");
companiesMapping.setXPath("aaa:companies");
companiesMapping.setUseXMLRoot(true);
// companiesMapping.setReferenceClass(Company.class);
xmlDescriptor.addMapping(companiesMapping);
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("aaa", "http://www.example.com/aaa");
xmlDescriptor.setNamespaceResolver(nsResolver);
return xmlDescriptor;
}
Aggregations