Package nl.nn.adapterframework.align
Class ToXml<C,N>
- java.lang.Object
-
- org.xml.sax.helpers.XMLFilterImpl
-
- nl.nn.adapterframework.align.XmlAligner
-
- nl.nn.adapterframework.align.ToXml<C,N>
-
- Type Parameters:
C
- containerN
- node
- All Implemented Interfaces:
ContentHandler
,DTDHandler
,EntityResolver
,ErrorHandler
,XMLFilter
,XMLReader
public abstract class ToXml<C,N> extends XmlAligner
Base class for XML Schema guided Object to XML conversion;- Author:
- Gerrit van Brakel
-
-
Field Summary
Fields Modifier and Type Field Description static String
MSG_CANNOT_NOT_FIND_ELEMENT_DECLARATION
static String
MSG_EXPECTED_ELEMENT
static String
MSG_INVALID_CONTENT
String
XSI_PREFIX_MAPPING
-
Fields inherited from class nl.nn.adapterframework.align.XmlAligner
FEATURE_NAMESPACE_PREFIXES, FEATURE_NAMESPACES, log, validatorHandler, XML_SCHEMA_INSTANCE_NAMESPACE, XML_SCHEMA_NIL_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description ToXml(ValidatorHandler validatorHandler, List<org.apache.xerces.xs.XSModel> schemaInformation)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Source
asSource(C container)
Obtain the XmlAligner as aSource
that can be used as input of aTransformer
.String
findNamespaceForName(String name)
abstract Map<String,String>
getAttributes(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
List<org.apache.xerces.xs.XSParticle>
getBestChildElementPath(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, boolean silent)
boolean
getBestMatchingElementPath(org.apache.xerces.xs.XSElementDeclaration baseElementDeclaration, N baseNode, org.apache.xerces.xs.XSParticle particle, List<org.apache.xerces.xs.XSParticle> path, List<String> failureReasons)
abstract Iterable<N>
getChildrenByName(N node, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration)
String
getNamespacePrefix(String uri)
String
getNodeNamespaceURI(N node)
return namespace of node, if known.String
getQName(String namespace, String name)
String
getRootElement()
abstract N
getRootNode(C container)
String
getTargetNamespace()
abstract String
getText(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
protected Set<String>
getUnprocessedChildElementNames(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, Set<String> processedChildren)
protected void
handleComplexTypedElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
void
handleElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
void
handleElementContents(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
void
handleError(String msg)
void
handleError(SAXException e)
void
handleRootNode(C container, String name, String nodeNamespace)
Pushes node through validator.protected void
handleSimpleTypedElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, org.apache.xerces.xs.XSSimpleTypeDefinition simpleTypeDefinition, N node)
abstract boolean
hasChild(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, String childName)
boolean
isDeepSearch()
boolean
isFailOnWildcards()
abstract boolean
isNil(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
void
parse(InputSource input)
Start the parse, obtain the container to parse from the InputSource when set byasSource(Object)
.protected void
processChildElement(N node, String parentName, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren)
protected void
sendString(String string)
void
setDeepSearch(boolean deepSearch)
void
setFailOnWildcards(boolean failOnWildcards)
void
setRootElement(String rootElement)
void
setTargetNamespace(String targetNamespace)
void
startParse(C container)
Align the XML according to the schema.String
translate(C data)
void
translate(C data, ContentHandler handler)
-
Methods inherited from class nl.nn.adapterframework.align.XmlAligner
collectChildElements, determineIsParentOfSingleMultipleOccurringChildElement, endElement, findElementDeclarationForName, findElementDeclarationsForName, findMultipleOccurringChildElements, getAttributeUses, getAttributeUses, getContext, getDocumentLocator, getElementType, getMultipleOccurringChildElements, getSchemaInformation, getSchemaInformation, getTypeDefinition, getTypeDefinition, getValidatorHandler, handleRecoverableError, isIgnoreUndeclaredElements, isMultipleOccurringChildElement, isMultipleOccurringChildInParentElement, isNil, isParentOfSingleMultipleOccurringChildElement, isPresentInSet, isTypeContainsWildcard, newLine, newLine, setDocumentLocator, setFeature, setIgnoreUndeclaredElements, setPsviProvider, setSchemaInformation, startDocument, startElement, typeContainsWildcard
-
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
characters, endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, processingInstruction, resolveEntity, setContentHandler, setDTDHandler, setEntityResolver, setErrorHandler, setParent, setProperty, skippedEntity, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
XSI_PREFIX_MAPPING
public final String XSI_PREFIX_MAPPING
- See Also:
- Constant Field Values
-
MSG_EXPECTED_ELEMENT
public static final String MSG_EXPECTED_ELEMENT
- See Also:
- Constant Field Values
-
MSG_INVALID_CONTENT
public static final String MSG_INVALID_CONTENT
- See Also:
- Constant Field Values
-
MSG_CANNOT_NOT_FIND_ELEMENT_DECLARATION
public static final String MSG_CANNOT_NOT_FIND_ELEMENT_DECLARATION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ToXml
public ToXml(ValidatorHandler validatorHandler, List<org.apache.xerces.xs.XSModel> schemaInformation)
-
-
Method Detail
-
getNodeNamespaceURI
public String getNodeNamespaceURI(N node)
return namespace of node, if known. If not, it will be determined from the schema.
-
asSource
public Source asSource(C container)
Obtain the XmlAligner as aSource
that can be used as input of aTransformer
.
-
parse
public void parse(InputSource input) throws SAXException, IOException
Start the parse, obtain the container to parse from the InputSource when set byasSource(Object)
. Normally, the parse is started via {#startParse(C container)}, but this implementation allowsasSource(Object)
to function.- Specified by:
parse
in interfaceXMLReader
- Overrides:
parse
in classXMLFilterImpl
- Throws:
SAXException
IOException
-
startParse
public void startParse(C container) throws SAXException
Align the XML according to the schema.- Throws:
SAXException
-
getAttributes
public abstract Map<String,String> getAttributes(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node) throws SAXException
- Throws:
SAXException
-
hasChild
public abstract boolean hasChild(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, String childName) throws SAXException
- Throws:
SAXException
-
getChildrenByName
public abstract Iterable<N> getChildrenByName(N node, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration) throws SAXException
- Throws:
SAXException
-
isNil
public abstract boolean isNil(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
-
getText
public abstract String getText(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node)
-
getUnprocessedChildElementNames
protected Set<String> getUnprocessedChildElementNames(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, Set<String> processedChildren) throws SAXException
- Throws:
SAXException
-
handleRootNode
public void handleRootNode(C container, String name, String nodeNamespace) throws SAXException
Pushes node through validator. Must push all nodes through validatorhandler, recursively, respecting the alignment request. Must set current=node before calling validatorHandler.startElement(), in order to get the right argument for the onStartElement / performAlignment callbacks.- Throws:
SAXException
-
handleElement
public void handleElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node) throws SAXException
- Throws:
SAXException
-
handleElementContents
public void handleElementContents(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node) throws SAXException
- Throws:
SAXException
-
handleComplexTypedElement
protected void handleComplexTypedElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node) throws SAXException
- Throws:
SAXException
-
handleSimpleTypedElement
protected void handleSimpleTypedElement(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, org.apache.xerces.xs.XSSimpleTypeDefinition simpleTypeDefinition, N node) throws SAXException
- Throws:
SAXException
-
processChildElement
protected void processChildElement(N node, String parentName, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren) throws SAXException
- Throws:
SAXException
-
getBestChildElementPath
public List<org.apache.xerces.xs.XSParticle> getBestChildElementPath(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, N node, boolean silent) throws SAXException
- Throws:
SAXException
-
getBestMatchingElementPath
public boolean getBestMatchingElementPath(org.apache.xerces.xs.XSElementDeclaration baseElementDeclaration, N baseNode, org.apache.xerces.xs.XSParticle particle, List<org.apache.xerces.xs.XSParticle> path, List<String> failureReasons) throws SAXException
- Parameters:
baseElementDeclaration
- TODOparticle
-failureReasons
- returns the reasons why no match was foundpath
- in this list the longest list of child elements, that matches the available, is maintained. Null if no matching.- Returns:
- true when a matching path is found. if false, failureReasons will contain reasons why.
- Throws:
SAXException
-
sendString
protected void sendString(String string) throws SAXException
- Throws:
SAXException
-
handleError
public void handleError(String msg) throws SAXException
- Throws:
SAXException
-
handleError
public void handleError(SAXException e) throws SAXException
- Throws:
SAXException
-
getQName
public String getQName(String namespace, String name) throws SAXException
- Throws:
SAXException
-
getNamespacePrefix
public String getNamespacePrefix(String uri) throws SAXException
- Throws:
SAXException
-
findNamespaceForName
public String findNamespaceForName(String name) throws SAXException
- Throws:
SAXException
-
translate
public void translate(C data, ContentHandler handler) throws SAXException
- Throws:
SAXException
-
translate
public String translate(C data) throws SAXException
- Throws:
SAXException
-
getRootElement
public String getRootElement()
-
setRootElement
public void setRootElement(String rootElement)
-
getTargetNamespace
public String getTargetNamespace()
-
setTargetNamespace
public void setTargetNamespace(String targetNamespace)
-
isDeepSearch
public boolean isDeepSearch()
-
setDeepSearch
public void setDeepSearch(boolean deepSearch)
-
isFailOnWildcards
public boolean isFailOnWildcards()
-
setFailOnWildcards
public void setFailOnWildcards(boolean failOnWildcards)
-
-