Class QualifyTargetNamespaceReferencesProcessor
java.lang.Object
org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement.QualifyTargetNamespaceReferencesProcessor
- All Implemented Interfaces:
NodeProcessor
NodeProcessor which prepends the target namespace prefix to any unprefixed
<xs:element ref="..."/> element references within a generated XML schema document.
Schemagen may emit unprefixed ref attributes when referencing elements in the target namespace
without declaring a default namespace (xmlns="...") on the root <xs:schema> element.
According to W3C XML Schema rules, unprefixed QNames in attribute values resolve against the default namespace,
so omitting both a prefix and a default namespace causes downstream validators (such as XJC) to report
src-resolve.4.1: Error resolving component ... It was detected that ... has no namespace.
This processor qualifies those references with the target namespace's prefix.
- Since:
- 4.1.1
- Author:
- Lennart Jörelid
-
Constructor Summary
ConstructorsConstructorDescriptionQualifyTargetNamespaceReferencesProcessor(String targetNamespacePrefix, boolean hasDefaultNamespace) Creates a new QualifyTargetNamespaceReferencesProcessor. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDefines if this visitor should process the provided node.intvoidProcesses the provided DOM Node.
-
Constructor Details
-
QualifyTargetNamespaceReferencesProcessor
public QualifyTargetNamespaceReferencesProcessor(String targetNamespacePrefix, boolean hasDefaultNamespace) Creates a new QualifyTargetNamespaceReferencesProcessor.- Parameters:
targetNamespacePrefix- The prefix associated with the schema's targetNamespace.hasDefaultNamespace-trueif the root<xs:schema>element declares a default namespace (i.e.xmlns="..."), in which case unprefixed QNames already legally resolve to it and must not be modified.
-
-
Method Details
-
getModifiedCount
public int getModifiedCount()- Returns:
- The number of element reference nodes modified by this processor.
-
accept
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
Processes the provided DOM Node.- Specified by:
processin interfaceNodeProcessor- Parameters:
aNode- The DOM Node to process.
-