org.eclipse.persistence.oxm.NamespaceResolver Maven / Gradle / Ivy
Show all versions of eclipselink Show documentation
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.oxm;
/**
* 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 org.eclipse.persistence.oxm.XMLDescriptor
* @see org.eclipse.persistence.eis.EISDescriptor
*
*/
public class NamespaceResolver extends org.eclipse.persistence.internal.oxm.NamespaceResolver {
/**
* Default constructor
*/
public NamespaceResolver() {
super();
}
/**
* Copy constructor
* @since EclipseLink 2.5.0
*/
public NamespaceResolver(NamespaceResolver namespaceResolver) {
super(namespaceResolver);
}
}