Class ChangeFilenameProcessor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement.ChangeFilenameProcessor
-
- All Implemented Interfaces:
NodeProcessor
public class ChangeFilenameProcessor extends java.lang.Object implements NodeProcessor
NodeProcessor which alters the filename for generated XML schema files. The ChangeNamespacePrefixProcessor alters the following:
- Schema Import Definitions
- <xs:import namespace="http://some/namespace" schemaLocation="schema2.xsd"/> is altered to <xs:import namespace="http://some/namespace" schemaLocation="anotherFile.xsd"/>
- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
IMPORT
private static java.lang.String
NAMESPACE
private java.util.Map<java.lang.String,java.lang.String>
namespaceUriToNewFilenameMap
private static java.lang.String
SCHEMA_LOCATION
-
Constructor Summary
Constructors Constructor Description ChangeFilenameProcessor(java.util.Map<java.lang.String,java.lang.String> namespaceUriToNewFilenameMap)
Creates a new ChangeFilenameProcessor using the provided map relating namespace URIs to desired new file names.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(org.w3c.dom.Node aNode)
Defines if this visitor should process the provided node.private java.lang.String
getNamespace(org.w3c.dom.Attr attribute)
Retrieves the value of the "namespace" attribute found within the parent element of the provided attribute.private boolean
isSchemaLocationAttributeForKnownNamespaceUri(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is a schemaLocation definition, which should be changed by this ChangeFilenameProcessor.void
process(org.w3c.dom.Node aNode)
Processes the provided DOM Node.
-
-
-
Field Detail
-
SCHEMA_LOCATION
private static final java.lang.String SCHEMA_LOCATION
- See Also:
- Constant Field Values
-
IMPORT
private static final java.lang.String IMPORT
- See Also:
- Constant Field Values
-
NAMESPACE
private static final java.lang.String NAMESPACE
- See Also:
- Constant Field Values
-
namespaceUriToNewFilenameMap
private java.util.Map<java.lang.String,java.lang.String> namespaceUriToNewFilenameMap
-
-
Constructor Detail
-
ChangeFilenameProcessor
public ChangeFilenameProcessor(java.util.Map<java.lang.String,java.lang.String> namespaceUriToNewFilenameMap)
Creates a new ChangeFilenameProcessor using the provided map relating namespace URIs to desired new file names.
- Parameters:
namespaceUriToNewFilenameMap
- A map relating namespace URIs [key] to new/desired schema filenames [value].
-
-
Method Detail
-
accept
public boolean accept(org.w3c.dom.Node aNode)
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
public void process(org.w3c.dom.Node aNode)
Processes the provided DOM Node.- Specified by:
process
in interfaceNodeProcessor
- Parameters:
aNode
- The DOM Node to process.
-
isSchemaLocationAttributeForKnownNamespaceUri
private boolean isSchemaLocationAttributeForKnownNamespaceUri(org.w3c.dom.Attr attribute)
Discovers if the provided attribute is a schemaLocation definition, which should be changed by this ChangeFilenameProcessor. Such an attribute is on the form<xs:import namespace="http://a/registered/namespace" schemaLocation="schema1.xsd"/>
.- Parameters:
attribute
- the attribute to test.- Returns:
true
if the provided attribute is a schemaLocation definition whose namespace is known to this ChangeFilenameProcessor.
-
getNamespace
private java.lang.String getNamespace(org.w3c.dom.Attr attribute)
Retrieves the value of the "namespace" attribute found within the parent element of the provided attribute.- Parameters:
attribute
- An attribute defined within the parent holding the "namespace" attribute.- Returns:
- The value of the "namespace" attribute.
-
-