public class XmlSchemaParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMPOSITE_XPATH_EXPR |
static java.lang.String |
ENUM_XPATH_EXPR |
static java.lang.String |
ERROR_HANDLER_KEY
Key for storing
ErrorHandler as user data in XML document |
static java.lang.String |
MESSAGE_SCHEMA_XPATH_EXPR |
static java.lang.String |
MESSAGE_XPATH_EXPR |
static java.lang.String |
SET_XPATH_EXPR |
static java.lang.String |
TYPE_XPATH_EXPR |
Constructor and Description |
---|
XmlSchemaParser() |
Modifier and Type | Method and Description |
---|---|
static void |
checkForValidName(org.w3c.dom.Node node,
java.lang.String name)
Check name against validity for C++ and Java naming.
|
static java.util.Map<java.lang.Long,Message> |
findMessages(org.w3c.dom.Document document,
javax.xml.xpath.XPath xPath,
java.util.Map<java.lang.String,Type> typeByNameMap)
Scan XML for all message definitions and save in map
|
static java.util.Map<java.lang.String,Type> |
findTypes(org.w3c.dom.Document document,
javax.xml.xpath.XPath xPath)
Scan XML for all types (encodedDataType, compositeType, enumType, and setType) and save in map
|
static java.lang.String |
getAttributeValue(org.w3c.dom.Node elementNode,
java.lang.String attrName)
Helper function that throws an exception when the attribute is not set.
|
static java.lang.String |
getAttributeValue(org.w3c.dom.Node elementNode,
java.lang.String attrName,
java.lang.String defValue)
Helper function that uses a default value when value not set.
|
static java.lang.String |
getAttributeValueOrNull(org.w3c.dom.Node elementNode,
java.lang.String attrName)
Helper function that hides the null return from
NamedNodeMap.getNamedItem(String) |
static java.nio.ByteOrder |
getByteOrder(java.lang.String byteOrderName)
Helper function to convert a schema byteOrderName into a
ByteOrder |
static void |
handleError(org.w3c.dom.Node node,
java.lang.String msg)
Handle an error condition as consequence of parsing.
|
static void |
handleWarning(org.w3c.dom.Node node,
java.lang.String msg)
Handle a warning condition as a consequence of parsing.
|
static MessageSchema |
parse(java.io.InputStream in,
ParserOptions options)
Take an
InputStream and parse it generating map of template ID to Message objects, types, and schema. |
static void |
validate(java.lang.String xsdFilename,
java.io.InputStream in)
Validate the document against a given schema.
|
public static final java.lang.String ERROR_HANDLER_KEY
ErrorHandler
as user data in XML documentpublic static final java.lang.String TYPE_XPATH_EXPR
public static final java.lang.String COMPOSITE_XPATH_EXPR
public static final java.lang.String ENUM_XPATH_EXPR
public static final java.lang.String SET_XPATH_EXPR
public static final java.lang.String MESSAGE_SCHEMA_XPATH_EXPR
public static final java.lang.String MESSAGE_XPATH_EXPR
public static void validate(java.lang.String xsdFilename, java.io.InputStream in) throws java.lang.Exception
System.err
xsdFilename
- schema to validate against.in
- document to be validated.java.lang.Exception
- if an error occurs when parsing the document or schema.public static MessageSchema parse(java.io.InputStream in, ParserOptions options) throws java.lang.Exception
InputStream
and parse it generating map of template ID to Message objects, types, and schema.
Exceptions are passed back up for any problems.
in
- stream from which schema is read.options
- to be applied during parsing.MessageSchema
encoding for the schema.java.lang.Exception
- on parsing error.public static java.util.Map<java.lang.String,Type> findTypes(org.w3c.dom.Document document, javax.xml.xpath.XPath xPath) throws java.lang.Exception
document
- for the XML parsingxPath
- for XPath expression reuseMap
of name String
to Typejava.lang.Exception
- on parsing error.public static java.util.Map<java.lang.Long,Message> findMessages(org.w3c.dom.Document document, javax.xml.xpath.XPath xPath, java.util.Map<java.lang.String,Type> typeByNameMap) throws java.lang.Exception
document
- for the XML parsingxPath
- for XPath expression reusetypeByNameMap
- to use for Type objectsMap
of schemaId to Messagejava.lang.Exception
- on parsing error.public static void handleError(org.w3c.dom.Node node, java.lang.String msg)
node
- that is the context of the warning.msg
- associated with the error.public static void handleWarning(org.w3c.dom.Node node, java.lang.String msg)
node
- as the context for the warning.msg
- associated with the warning.public static java.lang.String getAttributeValue(org.w3c.dom.Node elementNode, java.lang.String attrName)
elementNode
- that should have the attributeattrName
- that is to be looked upjava.lang.IllegalArgumentException
- if the attribute is not presentpublic static java.lang.String getAttributeValue(org.w3c.dom.Node elementNode, java.lang.String attrName, java.lang.String defValue)
elementNode
- that should have the attributeattrName
- that is to be looked updefValue
- String to return if not setpublic static java.lang.String getAttributeValueOrNull(org.w3c.dom.Node elementNode, java.lang.String attrName)
NamedNodeMap.getNamedItem(String)
elementNode
- that could be nullattrName
- that is to be looked uppublic static java.nio.ByteOrder getByteOrder(java.lang.String byteOrderName)
ByteOrder
byteOrderName
- specified as a FIX SBE stringpublic static void checkForValidName(org.w3c.dom.Node node, java.lang.String name)
node
- to have the name checked.name
- of the node to be checked.Copyright © 2014-2017 Real Logic Ltd. All Rights Reserved.