Package net.sf.saxon.ma.json
Class JsonHandlerXML
java.lang.Object
net.sf.saxon.ma.json.JsonHandler
net.sf.saxon.ma.json.JsonHandlerXML
Handler to generate an XML representation of JSON from a series of events
-
Field Summary
FieldsFields inherited from class net.sf.saxon.ma.json.JsonHandler
charChecker, escape
-
Constructor Summary
ConstructorsConstructorDescriptionJsonHandlerXML
(XPathContext context, String staticBaseUri, int flags) Make the handler to construct the XML tree representation for JSON -
Method Summary
Modifier and TypeMethodDescriptionvoid
endArray()
Close the current arrayvoid
endMap()
Close the current object/mapReturn the complete parsed resultprotected void
markAsEscaped
(String escaped, boolean isKey) boolean
Set the key to be written for the next entry in an object/mapvoid
setType
(String name, SchemaType st) Record a SchemaType for a particular namevoid
Open a new arrayvoid
startMap()
Start a new object/mapvoid
writeBoolean
(boolean value) Write a boolean valuevoid
Write a null valuevoid
writeNumeric
(String asString, AtomicValue parsedValue) Write a numeric valuevoid
writeString
(String val) Write a string valueMethods inherited from class net.sf.saxon.ma.json.JsonHandler
getContext, handleInvalidCharacters, reEscape, setContext, setFallbackFunction
-
Field Details
-
validate
public boolean validate -
PREFIX
- See Also:
-
types
-
-
Constructor Details
-
JsonHandlerXML
Make the handler to construct the XML tree representation for JSON- Parameters:
context
- the context in which the result tree is to be builtstaticBaseUri
- the static base URI, used for the base URI of the constructed treeflags
- flags indicating the chosen options- Throws:
XPathException
- if initialization fails, for example because of problems loading the schema
-
-
Method Details
-
setType
Record a SchemaType for a particular name- Parameters:
name
- the name to be used for the type, e.g. "arrayType"st
- the schema type to be used for typing such entities
-
setKey
Set the key to be written for the next entry in an object/map- Overrides:
setKey
in classJsonHandler
- Parameters:
unEscaped
- the key for the entry (null implies no key) in unescaped form (backslashes, if present, do not signal an escape sequence)reEscaped
- the key for the entry (null implies no key) in reescaped form. In this form special characters are represented as backslash-escaped sequences if the escape option is yes; if escape=no, the reEscaped form is the same as the unEscaped form.- Returns:
- true if the key is already present in the map, false if it is not
-
getResult
Return the complete parsed result- Overrides:
getResult
in classJsonHandler
- Returns:
- the XML document for this JSON
- Throws:
XPathException
- if an error occurs downstream
-
startArray
Open a new array- Overrides:
startArray
in classJsonHandler
- Throws:
XPathException
- if a dynamic error occurs
-
endArray
Close the current array- Overrides:
endArray
in classJsonHandler
- Throws:
XPathException
- if a dynamic error occurs
-
startMap
Start a new object/map- Overrides:
startMap
in classJsonHandler
- Throws:
XPathException
- if a dynamic error occurs
-
endMap
Close the current object/map- Overrides:
endMap
in classJsonHandler
- Throws:
XPathException
- if a dynamic error occurs
-
writeNumeric
Write a numeric value- Overrides:
writeNumeric
in classJsonHandler
- Parameters:
asString
- the string representation of the valueparsedValue
- the double representation of the value- Throws:
XPathException
- if a dynamic error occurs
-
writeString
Write a string value- Overrides:
writeString
in classJsonHandler
- Parameters:
val
- the string to be written. This will be in unescaped form if unescaping was requested in the flags, otherwise it may contain JSON escape sequences- Throws:
XPathException
- if a dynamic error occurs
-
markAsEscaped
- Overrides:
markAsEscaped
in classJsonHandler
- Throws:
XPathException
-
writeBoolean
Write a boolean value- Overrides:
writeBoolean
in classJsonHandler
- Parameters:
value
- the boolean value to be written- Throws:
XPathException
- if a dynamic error occurs
-
writeNull
Write a null value- Overrides:
writeNull
in classJsonHandler
- Throws:
XPathException
- if a dynamic error occurs
-