use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class SchemaTypeQNameProject method getQNameHolderDescriptor.
private XMLDescriptor getQNameHolderDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(QNameHolder.class);
descriptor.setDefaultRootElement("qnameholder");
XMLDirectMapping qnameMapping = new XMLDirectMapping();
qnameMapping.setAttributeName("theQName");
qnameMapping.setXPath("the-qname/text()");
((XMLField) qnameMapping.getField()).setSchemaType(XMLConstants.QNAME_QNAME);
descriptor.addMapping(qnameMapping);
XMLCompositeDirectCollectionMapping qnamesMapping = new XMLCompositeDirectCollectionMapping();
qnamesMapping.setAttributeName("theQNames");
qnamesMapping.setXPath("the-qnames/item/text()");
((XMLField) qnamesMapping.getField()).setSchemaType(XMLConstants.QNAME_QNAME);
descriptor.addMapping(qnamesMapping);
XMLCompositeDirectCollectionMapping qnames2Mapping = new XMLCompositeDirectCollectionMapping();
qnames2Mapping.setAttributeName("theQNames2");
qnames2Mapping.setXPath("the-qnames/item2/text()");
((XMLField) qnames2Mapping.getField()).setSchemaType(XMLConstants.QNAME_QNAME);
((XMLField) qnames2Mapping.getField()).setUsesSingleNode(true);
descriptor.addMapping(qnames2Mapping);
NamespaceResolver nr = new NamespaceResolver();
nr.put("somePrefix", "someURI");
nr.put("xsd", "http://www.w3.org/2001/XMLSchema");
nr.setDefaultNamespaceURI("mydefaultnamespace");
descriptor.setNamespaceResolver(nr);
return descriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class TypeAttributeNonXsiPrefixProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(NON_XSI_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLDirectMapping identifierMapping = new XMLDirectMapping();
identifierMapping.setAttributeName("identifier");
XMLField field = new XMLField("identifier/text()");
field.setIsTypedTextField(true);
identifierMapping.setField(field);
descriptor.addMapping(identifierMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class TypeAttributeTimeProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setDefaultRootElement("employee");
NamespaceResolver resolver = new NamespaceResolver();
resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
descriptor.setNamespaceResolver(resolver);
XMLDirectMapping identifierMapping = new XMLDirectMapping();
identifierMapping.setAttributeName("identifier");
XMLField field = new XMLField("identifier/text()");
field.setIsTypedTextField(true);
field.addConversion(XMLConstants.TIME_QNAME, GregorianCalendar.class);
identifierMapping.setField(field);
descriptor.addMapping(identifierMapping);
XMLDirectMapping firstNameMapping = new XMLDirectMapping();
firstNameMapping.setAttributeName("firstName");
firstNameMapping.setXPath("first-name/text()");
descriptor.addMapping(firstNameMapping);
XMLDirectMapping lastNameMapping = new XMLDirectMapping();
lastNameMapping.setAttributeName("lastName");
lastNameMapping.setXPath("last-name/text()");
descriptor.addMapping(lastNameMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class SelfAttributeProject method getEmployeeIDDescriptor.
private XMLDescriptor getEmployeeIDDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(EmployeeID.class);
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("ns", "urn:example");
descriptor.setNamespaceResolver(namespaceResolver);
XMLDirectMapping id1Mapping = new XMLDirectMapping();
id1Mapping.setAttributeName("id1");
id1Mapping.setXPath("@id1");
descriptor.addMapping(id1Mapping);
XMLDirectMapping id2Mapping = new XMLDirectMapping();
id2Mapping.setAttributeName("id2");
id2Mapping.setXPath("@ns:id2");
descriptor.addMapping(id2Mapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.
the class SelfAttributeProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.addPrimaryKeyFieldName("@id1");
descriptor.addPrimaryKeyFieldName("@ns:id2");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("ns", "urn:example");
descriptor.setNamespaceResolver(namespaceResolver);
XMLCompositeObjectMapping idMapping = new XMLCompositeObjectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath(".");
idMapping.setReferenceClass(EmployeeID.class);
descriptor.addMapping(idMapping);
XMLObjectReferenceMapping managerMapping = new XMLObjectReferenceMapping();
managerMapping.setAttributeName("manager");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/@fk1", "@id1");
managerMapping.addSourceToTargetKeyFieldAssociation("manager/@ns:fk2", "@ns:id2");
managerMapping.setReferenceClass(Employee.class);
descriptor.addMapping(managerMapping);
XMLCollectionReferenceMapping employeesMapping = new XMLCollectionReferenceMapping();
employeesMapping.setAttributeName("teamMembers");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/@fk1", "@id1");
employeesMapping.addSourceToTargetKeyFieldAssociation("team-member/@ns:fk2", "@ns:id2");
employeesMapping.setReferenceClass(Employee.class);
descriptor.addMapping(employeesMapping);
return descriptor;
}
Aggregations