Class NamespaceResolver

  • All Implemented Interfaces:
    XMLNamespaceResolver

    public class NamespaceResolver
    extends org.eclipse.persistence.internal.oxm.NamespaceResolver

    It is common for an XML document to include one or more namespaces. TopLink supports this using its NamespaceResolver. The namespace resolver maintains pairs of namespace prefixes and URIs. TopLink uses these prefixes in conjunction with the XPath statements you specify on EIS mappings to XML records and XML mappings.

    Although TopLink captures namespace prefixes in the XPath statements for mappings (if applicable), the input document is not required to use the same namespace prefixes. TopLink will use the namespace prefixes specified in the mapping when creating new documents.

    Code Sample
    NamespaceResolver resolver = new NamespaceResolver();
    resolver.put( "ns", "urn:namespace-example");

    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Customer.class);
    descriptor.setDefaultRootElement("ns:customer");
    descriptor.setNamespaceResolver(resolver);

    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("id");
    mapping.setXPath("ns:id/text()");
    descriptor.addMapping(mapping);

    See Also:
    XMLDescriptor, EISDescriptor
    • Method Summary

      • Methods inherited from class org.eclipse.persistence.internal.oxm.NamespaceResolver

        generatePrefix, generatePrefix, getDefaultNamespaceURI, getNamespaces, getPrefixes, getPrefixesToNamespaces, hasPrefix, hasPrefixesToNamespaces, put, removeNamespace, resolveNamespacePrefix, resolveNamespaceURI, setDefaultNamespaceURI, setDOM, setNamespaces
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NamespaceResolver

        public NamespaceResolver()
        Default constructor
      • NamespaceResolver

        public NamespaceResolver​(NamespaceResolver namespaceResolver)
        Copy constructor
        Since:
        EclipseLink 2.5.0