libyang REFACTOR prefix format always decides the callback (#1169)

So the callback is no longer needed as a parameter.
Also, union no longer uses its own prefix mappings
but instead uses the original format and copies any
required prefix data.
diff --git a/src/tree_data.h b/src/tree_data.h
index 37bfa0c..4f261ef 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -140,16 +140,25 @@
 
 /**
  * @brief Data input/output formats supported by libyang [parser](@ref howtodataparsers) and
- * [printer](@ref howtodataprinters) functions. Also used for value prefix format (TODO link to prefix formats descriptions).
+ * [printer](@ref howtodataprinters) functions.
  */
 typedef enum {
-    LYD_SCHEMA = 0,      /**< invalid instance data format, value prefixes map to YANG import prefixes */
-    LYD_XML,             /**< XML instance data format, value prefixes map to XML namespace prefixes */
-    LYD_JSON,            /**< JSON instance data format, value prefixes map to module names */
-    LYD_LYB,             /**< LYB instance data format, invalid value prefix format (same as LYD_JSON) */
+    LYD_UNKNOWN = 0,     /**< unknown data format, invalid value */
+    LYD_XML,             /**< XML instance data format */
+    LYD_JSON,            /**< JSON instance data format */
+    LYD_LYB,             /**< LYB instance data format */
 } LYD_FORMAT;
 
 /**
+ * @brief All kinds of supported prefix mappings to modules.
+ */
+typedef enum {
+    LY_PREF_SCHEMA,          /**< value prefixes map to YANG import prefixes */
+    LY_PREF_XML,             /**< value prefixes map to XML namespace prefixes */
+    LY_PREF_JSON,            /**< value prefixes map to module names */
+} LY_PREFIX_FORMAT;
+
+/**
  * @brief List of possible value types stored in ::lyd_node_any.
  */
 typedef enum {
@@ -167,6 +176,24 @@
 /** @} */
 
 /**
+ * @brief Special lyd_value structure for union.
+ *
+ * Represents data with multiple types (union). Original value is stored in the main lyd_value:canonical_cache while
+ * the lyd_value_subvalue::value contains representation according to one of the union's types.
+ * The lyd_value_subvalue:prefixes provides (possible) mappings from prefixes in the original value to YANG modules.
+ * These prefixes are necessary to parse original value to the union's subtypes.
+ */
+struct lyd_value_subvalue {
+    struct lyd_value *value;     /**< representation of the value according to the selected union's subtype
+                                      (stored as lyd_value::realpath here, in subvalue structure */
+    LY_PREFIX_FORMAT format;     /**< Prefix format of the value. However, this information is also used to decide
+                                      whether a value is valid for the specific format or not on later validations
+                                      (instance-identifier in XML looks different than in JSON). */
+    void *prefix_data;           /**< Format-specific data for prefix resolution (see ::ly_resolve_prefix) */
+    int parser_hint;             /**< Hint options from the parser */
+};
+
+/**
  * @brief YANG data representation
  */
 struct lyd_value {
@@ -186,23 +213,8 @@
         struct lysc_type_bitenum_item *enum_item;  /**< pointer to the definition of the enumeration value */
         struct lysc_type_bitenum_item **bits_items; /**< list of set pointers to the specification of the set bits ([sized array](@ref sizedarrays)) */
         struct lysc_ident *ident;    /**< pointer to the schema definition of the identityref value */
-
-        struct lyd_value_subvalue {
-            struct lyd_value_prefix {
-                const char *prefix;           /**< prefix string used in the canonized string to identify the mod of the YANG schema */
-                const struct lys_module *mod; /**< YANG schema module identified by the prefix string */
-            } *prefixes;                 /**< list of mappings between prefix in canonized value to a YANG schema ([sized array](@ref sizedarrays)) */
-            struct lyd_value *value;     /**< representation of the value according to the selected union's subtype (stored as lyd_value::realpath
-                                              here, in subvalue structure */
-            int parser_hint;             /**< Hint options from the parser */
-        } *subvalue;                     /**< data to represent data with multiple types (union). Original value is stored in the main
-                                              lyd_value:canonical_cache while the lyd_value_subvalue::value contains representation according to the
-                                              one of the union's type. The lyd_value_subvalue:prefixes provides (possible) mappings from prefixes
-                                              in original value to YANG modules. These prefixes are necessary to parse original value to the union's
-                                              subtypes. */
-
-        struct ly_path *target;          /**< Instance-identifier's target path. */
-
+        struct ly_path *target;      /**< Instance-identifier target path. */
+        struct lyd_value_subvalue *subvalue; /** Union value with some metadata. */
         void *ptr;                   /**< generic data type structure used to store the data */
     };  /**< The union is just a list of shorthands to possible values stored by a type's plugin. libyang itself uses the lyd_value::realtype
              plugin's callbacks to work with the data. */
@@ -302,37 +314,6 @@
 /** @} */
 
 /**
- * @brief Callback provided by the data/schema parsers to type plugins to resolve (format-specific) mapping between prefixes used
- * in the value strings to the YANG schemas.
- *
- * Reverse function to ly_get_prefix_clb.
- *
- * XML uses XML namespaces, JSON uses schema names as prefixes, YIN/YANG uses prefixes of the imports.
- *
- * @param[in] ctx libyang context to find the schema.
- * @param[in] prefix Prefix found in the value string
- * @param[in] prefix_len Length of the @p prefix.
- * @param[in] private Internal data needed by the callback.
- * @return Pointer to the YANG schema identified by the provided prefix or NULL if no mapping found.
- */
-typedef const struct lys_module *(*ly_resolve_prefix_clb)(const struct ly_ctx *ctx, const char *prefix, size_t prefix_len,
-                                                          void *private);
-
-/**
- * @brief Callback provided by the data/schema printers to type plugins to resolve (format-specific) mapping between YANG module of a data object
- * to prefixes used in the value strings.
- *
- * Reverse function to ly_resolve_prefix_clb.
- *
- * XML uses XML namespaces, JSON uses schema names as prefixes, YIN/YANG uses prefixes of the imports.
- *
- * @param[in] mod YANG module of the object.
- * @param[in] private Internal data needed by the callback.
- * @return String representing prefix for the object of the given YANG module @p mod.
- */
-typedef const char *(*ly_get_prefix_clb)(const struct lys_module *mod, void *private);
-
-/**
  * @brief Generic structure for a data node.
  */
 struct lyd_node {