Class ChangeNamespacePrefixProcessor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement.ChangeNamespacePrefixProcessor
-
- All Implemented Interfaces:
NodeProcessor
public class ChangeNamespacePrefixProcessor extends java.lang.Object implements NodeProcessor
NodeProcessorwhich alters the namespace prefix for all relevant Nodes within an XML document Node. It alters namespace prefixes in the following logical places:- Schema Namespace Definition
- xmlns:oldPrefix="http://some/namespace" is altered to xmlns:newPrefix="http://some/namespace"
- Elements Namespace Prefix
- <oldPrefix:someElement ... > is altered to <newPrefix:someElement ... >
- Element Reference
<xs:element ref="oldPrefix:aRequiredElementInTheOldPrefixNamespace"/>is altered to<xs:element ref="newPrefix:aRequiredElementInTheOldPrefixNamespace"/>- Type Attribute
<xs:element type="oldPrefix:something"/>is altered to<xs:element type="newPrefix:something"/>- Type Extension
<xs:extension base="oldPrefix:something"/>is altered to<xs:extension base="newPrefix:something"/>
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringEXTENSION_BASE_ATTRIBUTE_NAMEprivate static java.lang.StringEXTENSION_ELEMENT_NAMEprivate java.lang.StringnewPrefixprivate java.lang.StringoldPrefixprivate static java.lang.StringREFERENCE_ATTRIBUTE_NAMEprivate static java.lang.StringSCHEMAprivate static java.lang.StringTYPE_ATTRIBUTE_NAMEprivate static java.lang.StringXMLNS
-
Constructor Summary
Constructors Constructor Description ChangeNamespacePrefixProcessor(java.lang.String oldPrefix, java.lang.String newPrefix)Creates a new ChangeNamespacePrefixProcessor providing the oldPrefix which should be replaced by the newPrefix.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(org.w3c.dom.Node aNode)Defines if this visitor should process the provided node.private booleanisElementReference(org.w3c.dom.Attr attribute)Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the form<xs:element ref="oldPrefix:anElementInTheOldPrefixNamespace"/>private booleanisExtension(org.w3c.dom.Attr attribute)Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the formprivate booleanisNamespaceDefinition(org.w3c.dom.Attr attribute)Discovers if the provided attribute is the oldPrefix namespace definition, i.e.private booleanisTypeAttributeWithPrefix(org.w3c.dom.Attr attribute)Discovers if the provided attribute is a type attribute using the oldPrefix namespace, on the form<xs:element type="oldPrefix:anElementInTheOldPrefixNamespace"/>voidprocess(org.w3c.dom.Node aNode)Processes the provided DOM Node.
-
-
-
Field Detail
-
EXTENSION_ELEMENT_NAME
private static final java.lang.String EXTENSION_ELEMENT_NAME
- See Also:
- Constant Field Values
-
EXTENSION_BASE_ATTRIBUTE_NAME
private static final java.lang.String EXTENSION_BASE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
REFERENCE_ATTRIBUTE_NAME
private static final java.lang.String REFERENCE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
TYPE_ATTRIBUTE_NAME
private static final java.lang.String TYPE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
SCHEMA
private static final java.lang.String SCHEMA
- See Also:
- Constant Field Values
-
XMLNS
private static final java.lang.String XMLNS
- See Also:
- Constant Field Values
-
oldPrefix
private java.lang.String oldPrefix
-
newPrefix
private java.lang.String newPrefix
-
-
Constructor Detail
-
ChangeNamespacePrefixProcessor
public ChangeNamespacePrefixProcessor(java.lang.String oldPrefix, java.lang.String newPrefix)Creates a new ChangeNamespacePrefixProcessor providing the oldPrefix which should be replaced by the newPrefix.- Parameters:
oldPrefix- The old/current namespace prefixnewPrefix- The new/substituted namespace prefix
-
-
Method Detail
-
accept
public boolean accept(org.w3c.dom.Node aNode)
Defines if this visitor should process the provided node.- Specified by:
acceptin interfaceNodeProcessor- Parameters:
aNode- The DOM node to process.- Returns:
trueif the provided Node should be processed by this NodeProcessor.
-
process
public void process(org.w3c.dom.Node aNode)
Processes the provided DOM Node.- Specified by:
processin interfaceNodeProcessor- Parameters:
aNode- The DOM Node to process.
-
isNamespaceDefinition
private boolean isNamespaceDefinition(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is the oldPrefix namespace definition, i.e. if the given attribute is the xmlns:[oldPrefix] within the schema Element.- Parameters:
attribute- the attribute to test.- Returns:
trueif the provided attribute is the oldPrefix namespace definition, i.e. if the given attribute is the xmlns:[oldPrefix] within the schema Element.
-
isElementReference
private boolean isElementReference(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the form<xs:element ref="oldPrefix:anElementInTheOldPrefixNamespace"/>- Parameters:
attribute- the attribute to test.- Returns:
trueif the provided attribute is named "ref" and starts with[oldPrefix]:, in which case it is a reference to the oldPrefix namespace.
-
isTypeAttributeWithPrefix
private boolean isTypeAttributeWithPrefix(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is a type attribute using the oldPrefix namespace, on the form<xs:element type="oldPrefix:anElementInTheOldPrefixNamespace"/>- Parameters:
attribute- the attribute to test.- Returns:
trueif the provided attribute is named "type" and starts with[oldPrefix]:, in which case it is a type in the oldPrefix namespace.
-
isExtension
private boolean isExtension(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the form<xs:extension base="[oldPrefix]:importItem">- Parameters:
attribute- the attribute to test.- Returns:
trueif the provided attribute is named "extension" and starts with[oldPrefix]:, in which case it is a reference to the oldPrefix namespace.
-
-