Search in sources :

Example 21 with NamespaceResolver

use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.

the class XSDHelperProject method getRootDescriptor.

private XMLDescriptor getRootDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Root.class);
    XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
    schemaReference.setSchemaContext("/tns:root");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    xmlDescriptor.setSchemaReference(schemaReference);
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put("tns", "urn:xsd");
    xmlDescriptor.setNamespaceResolver(namespaceResolver);
    XMLCompositeObjectMapping child1Mapping = new XMLCompositeObjectMapping();
    child1Mapping.setAttributeName("child1");
    child1Mapping.setXPath("tns:child1");
    xmlDescriptor.addMapping(child1Mapping);
    XMLCompositeObjectMapping child2Mapping = new XMLCompositeObjectMapping();
    child2Mapping.setAttributeName("child2");
    child2Mapping.setXPath("tns:child2");
    xmlDescriptor.addMapping(child2Mapping);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 22 with NamespaceResolver

use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.

the class OppositeProject method getRootDescriptor.

private XMLDescriptor getRootDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Root.class);
    XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
    schemaReference.setSchemaContext("/tns:root");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    xmlDescriptor.setSchemaReference(schemaReference);
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put("tns", "urn:opposite");
    xmlDescriptor.setNamespaceResolver(namespaceResolver);
    XMLCompositeObjectMapping child1Mapping = new XMLCompositeObjectMapping();
    child1Mapping.setAttributeName("child1");
    child1Mapping.setXPath("tns:child1");
    xmlDescriptor.addMapping(child1Mapping);
    XMLCompositeObjectMapping child2Mapping = new XMLCompositeObjectMapping();
    child2Mapping.setAttributeName("child2");
    child2Mapping.setXPath("tns:child2");
    xmlDescriptor.addMapping(child2Mapping);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 23 with NamespaceResolver

use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.

the class MappingsProject method getChild2Descriptor.

private XMLDescriptor getChild2Descriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Child2.class);
    xmlDescriptor.setDefaultRootElement("tns:child2");
    xmlDescriptor.addPrimaryKeyFieldName("@id");
    XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
    schemaReference.setSchemaContext("/tns:child2");
    schemaReference.setType(XMLSchemaReference.ELEMENT);
    xmlDescriptor.setSchemaReference(schemaReference);
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put("tns", "urn:mappings");
    xmlDescriptor.setNamespaceResolver(namespaceResolver);
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    xmlDescriptor.addMapping(idMapping);
    XMLObjectReferenceMapping child1Mapping = new XMLObjectReferenceMapping();
    child1Mapping.setReferenceClass(Child1.class);
    child1Mapping.setAttributeName("child1");
    child1Mapping.addSourceToTargetKeyFieldAssociation("tns:child1/text()", "@id");
    xmlDescriptor.addMapping(child1Mapping);
    XMLObjectReferenceMapping child1AttributeMapping = new XMLObjectReferenceMapping();
    child1AttributeMapping.setReferenceClass(Child1.class);
    child1AttributeMapping.setAttributeName("child1Attribute");
    child1AttributeMapping.addSourceToTargetKeyFieldAssociation("@child1", "@id");
    xmlDescriptor.addMapping(child1AttributeMapping);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLObjectReferenceMapping(org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 24 with NamespaceResolver

use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.

the class IsSetProject method getRootDescriptor.

private XMLDescriptor getRootDescriptor() {
    XMLDescriptor xmlDescriptor = new XMLDescriptor();
    xmlDescriptor.setJavaClass(Root.class);
    xmlDescriptor.setDefaultRootElement("tns:root-element");
    XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
    schemaReference.setSchemaContext("/tns:root");
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    xmlDescriptor.setSchemaReference(schemaReference);
    NamespaceResolver namespaceResolver = new NamespaceResolver();
    namespaceResolver.put("tns", "urn:isset");
    xmlDescriptor.setNamespaceResolver(namespaceResolver);
    XMLCompositeObjectMapping mapping = new XMLCompositeObjectMapping();
    mapping.setReferenceClass(Child.class);
    if (mapping.getInverseReferenceMapping() != null) {
        mapping.getInverseReferenceMapping().setAttributeName("container");
    }
    mapping.setAttributeName("childProperty");
    mapping.setXPath("tns:child");
    xmlDescriptor.addMapping(mapping);
    XMLCompositeCollectionMapping mapping2 = new XMLCompositeCollectionMapping();
    mapping2.setReferenceClass(Child.class);
    if (mapping.getInverseReferenceMapping() != null) {
        mapping2.getInverseReferenceMapping().setAttributeName("container");
    }
    mapping2.setAttributeName("childCollectionProperty");
    mapping2.setXPath("tns:child-many");
    mapping2.getContainerPolicy().setContainerClass(ArrayList.class);
    xmlDescriptor.addMapping(mapping2);
    return xmlDescriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 25 with NamespaceResolver

use of org.eclipse.persistence.oxm.NamespaceResolver in project eclipselink by eclipse-ee4j.

the class OracleHelper method buildNewXMLDescriptor.

/**
 * Build an XMLDescriptor based on a given descriptor alias,
 * java class name schema alias, and target namespace.
 */
protected XMLDescriptor buildNewXMLDescriptor(String objectAlias, String javaClassName, String userType, String targetNamespace) {
    XMLDescriptor xdesc = new XMLDescriptor();
    xdesc.setAlias(objectAlias);
    xdesc.setJavaClassName(javaClassName);
    xdesc.getQueryManager();
    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext(SLASH + userType);
    schemaReference.setType(org.eclipse.persistence.platform.xml.XMLSchemaReference.COMPLEX_TYPE);
    xdesc.setSchemaReference(schemaReference);
    NamespaceResolver nr = new NamespaceResolver();
    nr.setDefaultNamespaceURI(targetNamespace);
    xdesc.setNamespaceResolver(nr);
    xdesc.setDefaultRootElement(userType);
    return xdesc;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver)

Aggregations

NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)227 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)142 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)74 XMLField (org.eclipse.persistence.oxm.XMLField)36 XMLSchemaClassPathReference (org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)36 Document (org.w3c.dom.Document)35 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)23 QName (javax.xml.namespace.QName)20 InputStream (java.io.InputStream)17 StringReader (java.io.StringReader)17 StringWriter (java.io.StringWriter)17 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)16 InputSource (org.xml.sax.InputSource)14 Element (org.w3c.dom.Element)13 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)12 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)12 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)10 HashMap (java.util.HashMap)9 Project (org.eclipse.persistence.sessions.Project)9 XMLConversionManager (org.eclipse.persistence.internal.oxm.XMLConversionManager)8