Class ChangeNamespacePrefixProcessor
java.lang.Object
org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement.ChangeNamespacePrefixProcessor
- All Implemented Interfaces:
NodeProcessor
NodeProcessor
which 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 -
Constructor Summary
ConstructorsConstructorDescriptionChangeNamespacePrefixProcessor
(String oldPrefix, String newPrefix) Creates a new ChangeNamespacePrefixProcessor providing the oldPrefix which should be replaced by the newPrefix. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Defines if this visitor should process the provided node.private boolean
isElementReference
(Attr attribute) Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the form<xs:element ref="oldPrefix:anElementInTheOldPrefixNamespace"/>
private boolean
isExtension
(Attr attribute) Discovers if the provided attribute is a namespace reference to the oldPrefix namespace, on the formprivate boolean
isNamespaceDefinition
(Attr attribute) Discovers if the provided attribute is the oldPrefix namespace definition, i.e.private boolean
isTypeAttributeWithPrefix
(Attr attribute) Discovers if the provided attribute is a type attribute using the oldPrefix namespace, on the form<xs:element type="oldPrefix:anElementInTheOldPrefixNamespace"/>
void
Processes the provided DOM Node.
-
Field Details
-
EXTENSION_ELEMENT_NAME
- See Also:
-
EXTENSION_BASE_ATTRIBUTE_NAME
- See Also:
-
REFERENCE_ATTRIBUTE_NAME
- See Also:
-
TYPE_ATTRIBUTE_NAME
- See Also:
-
SCHEMA
- See Also:
-
XMLNS
- See Also:
-
oldPrefix
-
newPrefix
-
-
Constructor Details
-
ChangeNamespacePrefixProcessor
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 Details
-
accept
Defines if this visitor should process the provided node.- Specified by:
accept
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM node to process.- Returns:
true
if the provided Node should be processed by this NodeProcessor.
-
process
Processes the provided DOM Node.- Specified by:
process
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM Node to process.
-
isNamespaceDefinition
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:
true
if the provided attribute is the oldPrefix namespace definition, i.e. if the given attribute is the xmlns:[oldPrefix] within the schema Element.
-
isElementReference
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:
true
if the provided attribute is named "ref" and starts with[oldPrefix]:
, in which case it is a reference to the oldPrefix namespace.
-
isTypeAttributeWithPrefix
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:
true
if the provided attribute is named "type" and starts with[oldPrefix]:
, in which case it is a type in the oldPrefix namespace.
-
isExtension
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:
true
if the provided attribute is named "extension" and starts with[oldPrefix]:
, in which case it is a reference to the oldPrefix namespace.
-