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);
XMLDescriptor
,
EISDescriptor
Constructor and Description |
---|
NamespaceResolver()
Default constructor
|
NamespaceResolver(NamespaceResolver namespaceResolver)
Copy constructor
|
generatePrefix, generatePrefix, getDefaultNamespaceURI, getNamespaces, getPrefixes, getPrefixesToNamespaces, hasPrefix, hasPrefixesToNamespaces, put, removeNamespace, resolveNamespacePrefix, resolveNamespaceURI, setDefaultNamespaceURI, setDOM, setNamespaces
public NamespaceResolver()
public NamespaceResolver(NamespaceResolver namespaceResolver)