parser REFACTOR specific data parsers defined together
diff --git a/src/lyb.h b/src/lyb.h
index 0aba895..27ba14f 100644
--- a/src/lyb.h
+++ b/src/lyb.h
@@ -27,6 +27,9 @@
 struct lyd_node;
 struct lysc_node;
 
+/**
+ * @brief LYB format parser context
+ */
 struct lylyb_ctx {
     const struct ly_ctx *ctx;
     uint64_t line;             /* current line */
@@ -49,35 +52,6 @@
 };
 
 /**
- * @brief Internal structure for LYB parser/printer.
- *
- * Note that the structure maps to the lyd_ctx which is common for all the data parsers
- */
-struct lyd_lyb_ctx {
-    const struct lysc_ext_instance *ext; /**< extension instance possibly changing document root context of the data being parsed */
-    union {
-        struct {
-            uint32_t parse_opts;   /**< various @ref dataparseroptions. */
-            uint32_t val_opts;     /**< various @ref datavalidationoptions. */
-        };
-        uint32_t print_options;
-    };
-    uint32_t int_opts;             /**< internal data parser options */
-    uint32_t path_len;             /**< used bytes in the path buffer */
-    char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
-    struct ly_set node_when;       /**< set of nodes with "when" conditions */
-    struct ly_set node_exts;       /**< set of nodes and extensions connected with a plugin providing own validation callback */
-    struct ly_set node_types;      /**< set of nodes validated with LY_EINCOMPLETE result */
-    struct ly_set meta_types;      /**< set of metadata validated with LY_EINCOMPLETE result */
-    struct lyd_node *op_node;      /**< if an RPC/action/notification is being parsed, store the pointer to it */
-
-    /* callbacks */
-    lyd_ctx_free_clb free;           /* destructor */
-
-    struct lylyb_ctx *lybctx;      /* lyb format context */
-};
-
-/**
  * @brief Destructor for the lylyb_ctx structure
  */
 void lyd_lyb_ctx_free(struct lyd_ctx *lydctx);
diff --git a/src/parser_internal.h b/src/parser_internal.h
index 0428e26..4681b13 100644
--- a/src/parser_internal.h
+++ b/src/parser_internal.h
@@ -69,6 +69,77 @@
 };
 
 /**
+ * @brief Internal context for XML data parser.
+ */
+struct lyd_xml_ctx {
+    const struct lysc_ext_instance *ext;
+    uint32_t parse_opts;
+    uint32_t val_opts;
+    uint32_t int_opts;
+    uint32_t path_len;
+    char path[LYD_PARSER_BUFSIZE];
+    struct ly_set node_when;
+    struct ly_set node_exts;
+    struct ly_set node_types;
+    struct ly_set meta_types;
+    struct lyd_node *op_node;
+
+    /* callbacks */
+    lyd_ctx_free_clb free;
+
+    struct lyxml_ctx *xmlctx;      /**< XML context */
+};
+
+/**
+ * @brief Internal context for JSON data parser.
+ */
+struct lyd_json_ctx {
+    const struct lysc_ext_instance *ext;
+    uint32_t parse_opts;
+    uint32_t val_opts;
+    uint32_t int_opts;
+    uint32_t path_len;
+    char path[LYD_PARSER_BUFSIZE];
+    struct ly_set node_when;
+    struct ly_set node_exts;
+    struct ly_set node_types;
+    struct ly_set meta_types;
+    struct lyd_node *op_node;
+
+    /* callbacks */
+    lyd_ctx_free_clb free;
+
+    struct lyjson_ctx *jsonctx;    /**< JSON context */
+};
+
+/**
+ * @brief Internal context for LYB data parser/printer.
+ */
+struct lyd_lyb_ctx {
+    const struct lysc_ext_instance *ext;
+    union {
+        struct {
+            uint32_t parse_opts;
+            uint32_t val_opts;
+        };
+        uint32_t print_options;
+    };
+    uint32_t int_opts;
+    uint32_t path_len;
+    char path[LYD_PARSER_BUFSIZE];
+    struct ly_set node_when;
+    struct ly_set node_exts;
+    struct ly_set node_types;
+    struct ly_set meta_types;
+    struct lyd_node *op_node;
+
+    /* callbacks */
+    lyd_ctx_free_clb free;
+
+    struct lylyb_ctx *lybctx;      /* LYB context */
+};
+
+/**
  * @brief Common part to supplement the specific ::lyd_ctx_free_clb callbacks.
  */
 void lyd_ctx_free(struct lyd_ctx *);
diff --git a/src/parser_json.c b/src/parser_json.c
index 3ac0542..c47b47f 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -36,30 +36,6 @@
 #include "validation.h"
 
 /**
- * @brief Internal context for JSON YANG data parser.
- *
- * Note that the structure maps to the lyd_ctx which is common for all the data parsers
- */
-struct lyd_json_ctx {
-    const struct lysc_ext_instance *ext; /**< extension instance possibly changing document root context of the data being parsed */
-    uint32_t parse_opts;           /**< various @ref dataparseroptions. */
-    uint32_t val_opts;             /**< various @ref datavalidationoptions. */
-    uint32_t int_opts;             /**< internal data parser options */
-    uint32_t path_len;             /**< used bytes in the path buffer */
-    char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
-    struct ly_set node_when;       /**< set of nodes with "when" conditions */
-    struct ly_set node_exts;       /**< set of nodes and extensions connected with a plugin providing own validation callback */
-    struct ly_set node_types;      /**< set of nodes validated with LY_EINCOMPLETE result */
-    struct ly_set meta_types;      /**< set of metadata validated with LY_EINCOMPLETE result */
-    struct lyd_node *op_node;      /**< if an RPC/action/notification is being parsed, store the pointer to it */
-
-    /* callbacks */
-    lyd_ctx_free_clb free;           /* destructor */
-
-    struct lyjson_ctx *jsonctx;    /**< JSON context */
-};
-
-/**
  * @brief Free the JSON data parser context.
  *
  * JSON implementation of lyd_ctx_free_clb().
diff --git a/src/parser_xml.c b/src/parser_xml.c
index a61ca39..38fb07a 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -33,30 +33,6 @@
 #include "validation.h"
 #include "xml.h"
 
-/**
- * @brief Internal context for XML YANG data parser.
- *
- * Note that the structure maps to the ::lyd_ctx which is common for all the data parsers
- */
-struct lyd_xml_ctx {
-    const struct lysc_ext_instance *ext; /**< extension instance possibly changing document root context of the data being parsed */
-    uint32_t parse_opts;           /**< various @ref dataparseroptions. */
-    uint32_t val_opts;             /**< various @ref datavalidationoptions. */
-    uint32_t int_opts;             /**< internal data parser options */
-    uint32_t path_len;             /**< used bytes in the path buffer */
-    char path[LYD_PARSER_BUFSIZE]; /**< buffer for the generated path */
-    struct ly_set node_when;       /**< set of nodes with "when" conditions */
-    struct ly_set node_exts;       /**< set of nodes and extensions connected with a plugin providing own validation callback */
-    struct ly_set node_types;      /**< set of nodes validated with LY_EINCOMPLETE result */
-    struct ly_set meta_types;      /**< set of metadata validated with LY_EINCOMPLETE result */
-    struct lyd_node *op_node;      /**< if an RPC/action/notification is being parsed, store the pointer to it */
-
-    /* callbacks */
-    lyd_ctx_free_clb free;           /* destructor */
-
-    struct lyxml_ctx *xmlctx;      /**< XML context */
-};
-
 void
 lyd_xml_ctx_free(struct lyd_ctx *lydctx)
 {