Class QualifyTargetNamespaceReferencesProcessor
- java.lang.Object
-
- org.codehaus.mojo.jaxb2.schemageneration.postprocessing.schemaenhancement.QualifyTargetNamespaceReferencesProcessor
-
- All Implemented Interfaces:
NodeProcessor
public class QualifyTargetNamespaceReferencesProcessor extends Object implements NodeProcessor
NodeProcessorwhich prepends the target namespace prefix to any unprefixed<xs:element ref="..."/>element references within a generated XML schema document.Schemagen may emit unprefixed
refattributes 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 reportsrc-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
Constructors Constructor Description QualifyTargetNamespaceReferencesProcessor(String targetNamespacePrefix, boolean hasDefaultNamespace)Creates a new QualifyTargetNamespaceReferencesProcessor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(Node aNode)Defines if this visitor should process the provided node.intgetModifiedCount()voidprocess(Node aNode)Processes the provided DOM Node.
-
-
-
Constructor Detail
-
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 Detail
-
getModifiedCount
public int getModifiedCount()
- Returns:
- The number of element reference nodes modified by this processor.
-
accept
public boolean accept(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(Node aNode)
Processes the provided DOM Node.- Specified by:
processin interfaceNodeProcessor- Parameters:
aNode- The DOM Node to process.
-
-