Class NamespaceResolver

java.lang.Object
org.eclipse.persistence.internal.oxm.NamespaceResolver
org.eclipse.persistence.oxm.NamespaceResolver
All Implemented Interfaces:
XMLNamespaceResolver
Direct Known Subclasses:
NamespaceResolverWithPrefixes, PrefixMapperNamespaceResolver

public class NamespaceResolver extends 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:
  • Constructor Details

    • NamespaceResolver

      public NamespaceResolver()
      Default constructor
    • NamespaceResolver

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