public class XmlSchemaParser extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ERROR_HANDLER_KEY
Key for storing
ErrorHandler as user data in XML document. |
| Constructor and Description |
|---|
XmlSchemaParser() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkForValidName(Node node,
String name)
Check name against validity for C++ and Java naming.
|
static Map<Long,Message> |
findMessages(Document document,
XPath xPath,
Map<String,Type> typeByNameMap)
Scan XML for all message definitions and save in map.
|
static Map<String,Type> |
findTypes(Document document,
XPath xPath)
Scan XML for all types (encodedDataType, compositeType, enumType, and setType) and save in a map.
|
static String |
getAttributeValue(Node elementNode,
String attrName)
Helper function that throws an exception when the attribute is not set.
|
static String |
getAttributeValue(Node elementNode,
String attrName,
String defValue)
Helper function that uses a default value when value not set.
|
static String |
getAttributeValueOrNull(Node elementNode,
String attrName)
Helper function that hides the null return from
NamedNodeMap.getNamedItem(String). |
static ByteOrder |
getByteOrder(String byteOrderName)
Helper function to convert a schema byteOrderName into a
ByteOrder. |
static String |
getTypesPackageAttribute(Node elementNode)
To be used with descendant elements of
<types> elements. |
static void |
handleError(Node node,
String msg)
Handle an error condition as consequence of parsing.
|
static void |
handleWarning(Node node,
String msg)
Handle a warning condition as a consequence of parsing.
|
static MessageSchema |
parse(InputSource is,
ParserOptions options)
Take an
InputSource and parse it generating map of template ID to Message objects, types, and schema. |
static MessageSchema |
parse(InputStream in,
ParserOptions options)
|
static void |
validate(String xsdFilename,
InputSource is,
ParserOptions options)
Validate the document against a given schema.
|
static void |
validate(String xsdFilename,
InputStream in,
ParserOptions options)
Wraps the
InputStream into an InputSource and delegates to
validate(String, InputSource, ParserOptions). |
public static final String ERROR_HANDLER_KEY
ErrorHandler as user data in XML document.public static void validate(String xsdFilename, InputSource is, ParserOptions options) throws Exception
System.err.xsdFilename - schema to validate against.is - source from which schema is read. Ideally it will have the systemId property set to resolve
relative references.options - to be applied during parsing.Exception - if an error occurs when parsing the document or schema.public static void validate(String xsdFilename, InputStream in, ParserOptions options) throws Exception
InputStream into an InputSource and delegates to
validate(String, InputSource, ParserOptions).
Note: this method does not set the InputSource.setSystemId(java.lang.String) property.
However, it is recommended to use the validate(String, InputSource, ParserOptions) method directly.
xsdFilename - schema to validate against.in - document to be validated.options - to be applied during parsing.Exception - if an error occurs when parsing the document or schema.public static MessageSchema parse(InputSource is, ParserOptions options) throws Exception
InputSource and parse it generating map of template ID to Message objects, types, and schema.is - source from which schema is read. Ideally it will have the systemId property set to resolve
relative references.options - to be applied during parsing.MessageSchema encoding for the schema.Exception - on parsing error.public static MessageSchema parse(InputStream in, ParserOptions options) throws Exception
InputStream into an InputSource and delegates to
parse(InputSource, ParserOptions).
Note: this method does not set the InputSource.setSystemId(java.lang.String) property.
However, it is recommended to use the parse(InputSource, ParserOptions) method directly.
in - stream from which schema is read.options - to be applied during parsing.MessageSchema encoding for the schema.Exception - on parsing error.public static Map<String,Type> findTypes(Document document, XPath xPath) throws XPathExpressionException
document - for the XML parsing.xPath - for XPath expression reuse.Map of name String to Type.XPathExpressionException - on parsing error.public static Map<Long,Message> findMessages(Document document, XPath xPath, Map<String,Type> typeByNameMap) throws XPathExpressionException
document - for the XML parsing.xPath - for XPath expression reuse.typeByNameMap - to use for Type objects.Map of schemaId to Message.XPathExpressionException - on parsing error.public static void handleError(Node node, String msg)
node - that is the context of the warning.msg - associated with the error.public static void handleWarning(Node node, String msg)
node - as the context for the warning.msg - associated with the warning.public static String getAttributeValue(Node elementNode, String attrName)
elementNode - that should have the attribute.attrName - that is to be looked up.IllegalStateException - if the attribute is not present.public static String getAttributeValue(Node elementNode, String attrName, String defValue)
elementNode - that should have the attribute.attrName - that is to be looked up.defValue - value to return if not set.public static String getTypesPackageAttribute(Node elementNode)
<types> elements. Returns the package attribute value as
defined on the ancestor <types> element.elementNode - the node inside the <types> element.public static String getAttributeValueOrNull(Node elementNode, String attrName)
NamedNodeMap.getNamedItem(String).elementNode - that could be null.attrName - that is to be looked up.public static ByteOrder getByteOrder(String byteOrderName)
ByteOrder.byteOrderName - specified as a FIX SBE string.Copyright © 2013-2024 Real Logic Limited. All Rights Reserved.