Class XmlToJson<Xml>

  • Type Parameters:
    Xml - The type of the xml representation used by the calling code.

    public final class XmlToJson<Xml>
    extends Object
    A tool to convert some XML representation of the Revapi configuration to JsonNode used by Revapi.
    Since:
    0.8.0
    Author:
    Lukas Krejci
    • Constructor Detail

      • XmlToJson

        @Deprecated
        public XmlToJson​(Map<String,​org.jboss.dmr.ModelNode> knownExtensionSchemas,
                         Function<Xml,​String> getName,
                         Function<Xml,​String> getValue,
                         BiFunction<Xml,​String,​String> getAttributeValue,
                         Function<Xml,​List<Xml>> getChildren)
        Deprecated.
        use the Jackson-based variant
        Constructs a new XML to JSON converter. To be able to navigate the XML and to convert to JSON data types correctly, the instance needs to know about the schemas used by various extensions.
        Parameters:
        knownExtensionSchemas - the schemas of the known extensions. Keys are extension ids, values are extension schemas
        getName - a function that gets the name of an XML tag
        getValue - a function that gets the textual value of an XML node, e.g. it's textual content.
        getAttributeValue - a function to get a value of an attribute of an XML node
        getChildren - a function that gets the children of an XML node. Note that the returned list MUST NOT contain any text or CDATA nodes - those are to be used in the getValue function. It also MUST NOT contain any comment nodes.
    • Method Detail

      • fromKnownSchemas

        public static <Xml> XmlToJson<Xml> fromKnownSchemas​(Map<String,​com.fasterxml.jackson.databind.JsonNode> knownExtensionSchemas,
                                                            Function<Xml,​String> getName,
                                                            Function<Xml,​String> getValue,
                                                            BiFunction<Xml,​String,​String> getAttributeValue,
                                                            Function<Xml,​List<Xml>> getChildren)
        Constructs a new XML to JSON converter. To be able to navigate the XML and to convert to JSON data types correctly, the instance needs to know about the schemas used by various extensions.
        Parameters:
        knownExtensionSchemas - the schemas of the known extensions. Keys are extension ids, values are extension schemas
        getName - a function that gets the name of an XML tag
        getValue - a function that gets the textual value of an XML node, e.g. it's textual content.
        getAttributeValue - a function to get a value of an attribute of an XML node
        getChildren - a function that gets the children of an XML node. Note that the returned list MUST NOT contain any text or CDATA nodes - those are to be used in the getValue function. It also MUST NOT contain any comment nodes.
      • convertXml

        public com.fasterxml.jackson.databind.JsonNode convertXml​(Xml xml)