Class Json2Xml

All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

public class Json2Xml extends Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
XML Schema guided JSON to XML converter;
Author:
Gerrit van Brakel
  • Field Details

  • Constructor Details

    • Json2Xml

      public Json2Xml(ValidatorHandler validatorHandler, List<org.apache.xerces.xs.XSModel> schemaInformation, boolean insertElementContainerElements, String rootElement)
    • Json2Xml

      public Json2Xml(ValidatorHandler validatorHandler, List<org.apache.xerces.xs.XSModel> schemaInformation, boolean insertElementContainerElements, String rootElement, boolean strictSyntax)
  • Method Details

    • startParse

      public void startParse(jakarta.json.JsonValue node) throws SAXException
      Description copied from class: ToXml
      Align the XML according to the schema.
      Overrides:
      startParse in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • getRootNode

      public jakarta.json.JsonValue getRootNode(jakarta.json.JsonValue container)
      Specified by:
      getRootNode in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
    • handleElementContents

      public void handleElementContents(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node) throws SAXException
      Overrides:
      handleElementContents in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • getNodeText

      public String getNodeText(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node)
      Specified by:
      getNodeText in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
    • isNil

      public boolean isNil(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node)
      Specified by:
      isNil in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
    • getAttributes

      public Map<String,String> getAttributes(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node) throws SAXException
      Specified by:
      getAttributes in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • hasChild

      public boolean hasChild(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node, String childName) throws SAXException
      Overrides:
      hasChild in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • getAllNodeChildNames

      public Set<String> getAllNodeChildNames(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node) throws SAXException
      Specified by:
      getAllNodeChildNames in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • getNodeChildrenByName

      public Iterable<jakarta.json.JsonValue> getNodeChildrenByName(jakarta.json.JsonValue node, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration) throws SAXException
      Specified by:
      getNodeChildrenByName in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • getSubstitutedChild

      protected jakarta.json.JsonValue getSubstitutedChild(jakarta.json.JsonValue node, String childName)
      Description copied from class: Tree2Xml
      Allows subclasses to provide a special way of substituting. This is used by Json2Xml to insert a List of values as a JsonArray.
      Overrides:
      getSubstitutedChild in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
    • getOverride

      protected String getOverride(org.apache.xerces.xs.XSElementDeclaration elementDeclaration, jakarta.json.JsonValue node)
      Overrides:
      getOverride in class Tree2Xml<jakarta.json.JsonValue,jakarta.json.JsonValue>
    • processChildElement

      protected void processChildElement(jakarta.json.JsonValue node, String parentName, org.apache.xerces.xs.XSElementDeclaration childElementDeclaration, boolean mandatory, Set<String> processedChildren) throws SAXException
      Overrides:
      processChildElement in class ToXml<jakarta.json.JsonValue,jakarta.json.JsonValue>
      Throws:
      SAXException
    • translate

      public static String translate(String json, URL schemaURL, boolean compactJsonArrays, String rootElement, String targetNamespace) throws SAXException
      Throws:
      SAXException
    • translate

      public static String translate(jakarta.json.JsonStructure jsonStructure, URL schemaURL, boolean compactJsonArrays, String rootElement, String targetNamespace) throws SAXException
      Throws:
      SAXException
    • translate

      public static String translate(jakarta.json.JsonStructure json, URL schemaURL, boolean compactJsonArrays, String rootElement, boolean strictSyntax, boolean deepSearch, String targetNamespace, Map<String,Object> overrideValues) throws SAXException
      Throws:
      SAXException
    • create

      public static Json2Xml create(URL schemaURL, boolean compactJsonArrays, String rootElement, boolean strictSyntax, boolean deepSearch, String targetNamespace, Map<String,Object> overrideValues) throws SAXException
      Throws:
      SAXException
    • isReadAttributes

      public boolean isReadAttributes()
    • setReadAttributes

      public void setReadAttributes(boolean readAttributes)