Class JsonHandlerXML

  • public class JsonHandlerXML
    extends JsonHandler
    Handler to generate an XML representation of JSON from a series of events
    • Field Detail

      • validate

        public boolean validate
      • types

        public java.util.HashMap<java.lang.String,​SchemaType> types
    • Constructor Detail

      • JsonHandlerXML

        public JsonHandlerXML​(XPathContext context,
                              java.lang.String staticBaseUri,
                              int flags)
                       throws XPathException
        Make the handler to construct the XML tree representation for JSON
        context - the context in which the result tree is to be built
        staticBaseUri - the static base URI, used for the base URI of the constructed tree
        flags - flags indicating the chosen options
        XPathException - if initialization fails, for example because of problems loading the schema
    • Method Detail

      • setType

        public void setType​(java.lang.String name,
                            SchemaType st)
        Record a SchemaType for a particular name
        name - the name to be used for the type, e.g. "arrayType"
        st - the schema type to be used for typing such entities
      • setKey

        public boolean setKey​(java.lang.String unEscaped,
                              java.lang.String reEscaped)
        Set the key to be written for the next entry in an object/map
        setKey in class JsonHandler
        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.
        true if the key is already present in the map, false if it is not
      • writeNumeric

        public void writeNumeric​(java.lang.String asString,
                                 AtomicValue parsedValue)
                          throws XPathException
        Write a numeric value
        writeNumeric in class JsonHandler
        asString - the string representation of the value
        parsedValue - the double representation of the value
        XPathException - if a dynamic error occurs
      • writeString

        public void writeString​(java.lang.String val)
                         throws XPathException
        Write a string value
        writeString in class JsonHandler
        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
        XPathException - if a dynamic error occurs