Package uk.blankaspect.common.jsonxml
Class JsonXmlValidator
java.lang.Object
uk.blankaspect.common.jsonxml.JsonXmlValidator
This class provides some
static methods for validating a tree of JSON-XML elements against an XML Schema
(XSD).
- A method that validates a JSON-XML tree against one of two predefined schemas according to a flag that is an argument of the method. One schema has a target namespace; the other does not have a target namespace.
- A method that validates a JSON-XML tree against a schema that is created from a resource at a specified location.
- A method that validates a JSON-XML tree against a schema that is created from a file at a specified file-system location.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the namespace in the XML Schema for JSON-XML that has a target namespace. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidValidates a tree of JSON-XML elements whose root is the specified element against an XML Schema (XSD) that is created from a resource at the specified location.static voidValidates a tree of JSON-XML elements whose root is the specified element against an XML Schema (XSD) that is created from a file at the specified file-system location.static voidValidates a tree of JSON-XML elements whose root is the specified element against one of two predefined XML Schemas (XSD) according to the specified flag.
-
Field Details
-
NAMESPACE_NAME
The name of the namespace in the XML Schema for JSON-XML that has a target namespace.- See Also:
-
-
Method Details
-
validate
Validates a tree of JSON-XML elements whose root is the specified element against one of two predefined XML Schemas (XSD) according to the specified flag. One schema has a target namespace; the other does not have a target namespace.- Parameters:
element- the root of the tree of JSON-XML elements that will be validated against one of two predefined schemas according tohasTargetNamespace.hasTargetNamespace- iftrue, the JSON-XML tree will be validated against a schema that has a target namespace; iffalse, the JSON-XML tree will be validated against a schema that does not have a target namespace.- Throws:
BaseException- if an error occurs when validating the tree of JSON-XML elements.
-
validate
Validates a tree of JSON-XML elements whose root is the specified element against an XML Schema (XSD) that is created from a resource at the specified location.- Parameters:
cls- the class with which the schema-file resource is associated. If it isnull, the system class loader will be used to find the resource.xsdPathname- the pathname of the schema-file resource.element- the root of the tree of JSON-XML elements that will be validated.- Throws:
BaseException- if an error occurs when- loading the schema-file resource,
- creating an XML Schema from the resource, or
- validating the tree of JSON-XML elements.
-
validate
Validates a tree of JSON-XML elements whose root is the specified element against an XML Schema (XSD) that is created from a file at the specified file-system location.- Parameters:
xsdFile- the file-system location of the schema file.element- the root of the tree of JSON-XML elements that will be validated.- Throws:
BaseException- if an error occurs when- reading the schema file,
- creating an XML Schema from the contents of the file, or
- validating the tree of JSON-XML elements.
-