00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QSF_XML_H
00025 #define QSF_XML_H
00026
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <regex.h>
00035 #include <time.h>
00036 #include "qof.h"
00037
00038 #include <libintl.h>
00039 #define _(String) dgettext (GETTEXT_PACKAGE, String)
00040
00041 typedef enum
00042 {
00044 QSF_UNDEF = 0,
00046 IS_QSF_MAP,
00048 IS_QSF_OBJ,
00050 HAVE_QSF_MAP,
00052 OUR_QSF_OBJ,
00053 } QsfType;
00054
00063 typedef struct QsfObject_s
00064 {
00065 GHashTable *parameters;
00066 QofIdType object_type;
00067 gint object_count;
00068 } QsfObject;
00069
00070 #define QSF_QOF_VERSION QOF_OBJECT_VERSION
00078 #define QSF_ROOT_TAG "qof-qsf"
00079
00084 #define QSF_DEFAULT_NS "http://qof.sourceforge.net/"
00085
00088 #define QSF_DATE_LENGTH MAX_DATE_LENGTH
00089
00091 #define QSF_BOOK_TAG "book"
00092
00094 #define QSF_BOOK_GUID "book-guid"
00095
00096 #define QSF_BOOK_COUNT "count"
00097
00098 #define QSF_OBJECT_TAG "object"
00099
00100 #define QSF_OBJECT_TYPE "type"
00101
00102 #define QSF_OBJECT_COUNT "count"
00103
00104 #define QSF_XML_VERSION "1.0"
00105
00124 #define QSF_OBJECT_KVP "path"
00125
00126 #define QSF_OBJECT_VALUE "value"
00127
00133 #define MAP_ROOT_TAG "qsf-map"
00134
00144 #define MAP_DEFINITION_TAG "definition"
00145
00151 #define MAP_DEFINE_TAG "define"
00152
00155 #define MAP_ITERATE_ATTR "foreach"
00156
00226 #define MAP_DEFAULT_TAG "default"
00227
00237 #define MAP_OBJECT_TAG "object"
00238
00248 #define MAP_CALCULATE_TAG "calculate"
00249
00257 #define MAP_QOF_VERSION "qof_version"
00258
00267 #define MAP_NAME_ATTR "name"
00268
00276 #define MAP_TYPE_ATTR "type"
00277
00286 #define MAP_VALUE_ATTR "value"
00287
00290 #define MAP_OBJECT_ATTR "object"
00291
00300 #define MAP_E_TYPE "e_type"
00301
00304 #define MAP_ENUM_TYPE "enum"
00305
00307 #define QSF_BOOLEAN_DEFAULT "boolean"
00308
00319 #define QSF_CONDITIONAL "if"
00320
00331 #define QSF_CONDITIONAL_SET "set"
00332
00355 #define QSF_CONDITIONAL_ELSE "else"
00356
00363 #define QSF_OPTION "option"
00364
00373 #define QSF_FORMATTING_OPTION "format"
00374
00411 #define QSF_XSD_TIME QOF_UTC_DATE_FORMAT
00412
00414 #define QSF_XML_BOOLEAN_TEST "true"
00415
00417 #define QSF_OBJECT_SCHEMA "qsf-object.xsd.xml"
00418
00420 #define QSF_MAP_SCHEMA "qsf-map.xsd.xml"
00421
00443 typedef enum
00444 {
00446 QSF_NO_OBJECT = 0,
00450 QSF_DEFINED_OBJECT,
00453 QSF_REGISTERED_OBJECT,
00455 QSF_CALCULATED_OBJECT,
00457 QSF_INVALID_OBJECT
00458 } QsfStatus;
00459
00466 typedef struct QsfMetadata_s
00467 {
00469 QsfType file_type;
00471 QsfObject *object_set;
00473 gint count;
00475 GList *qsf_object_list;
00477 GSList *qsf_sequence;
00479 GList *referenceList;
00481 GHashTable *qsf_parameter_hash, *qsf_define_hash;
00482 GHashTable *qsf_calculate_hash, *qsf_default_hash;
00484 GSList *supported_types;
00486 xmlDocPtr input_doc;
00488 xmlDocPtr output_doc;
00490 xmlNodePtr child_node;
00492 xmlNodePtr convert_node;
00494 xmlNodePtr param_node;
00496 xmlNodePtr output_node;
00498 xmlNodePtr output_root;
00500 xmlNodePtr book_node;
00502 xmlNodePtr lister;
00504 xmlNsPtr qsf_ns, map_ns;
00506 const gchar *qof_type;
00508 QofIdType qof_obj_type;
00510 QofIdType qof_foreach;
00512 gint foreach_limit;
00514 QofEntity *qsf_ent;
00516 QofBackend *be;
00518 gboolean knowntype;
00520 QofParam *qof_param;
00526 QofBook *book;
00528 gint boolean_calculation_done;
00530 gchar *filepath;
00532 gchar *map_path;
00534 gchar *full_kvp_path;
00536 gint64 use_gz_level;
00542 GList *map_files;
00544 const gchar *encoding;
00546 gint64 convert;
00547 QofErrorId err_nomap, err_overflow;
00548 } QsfParam;
00549
00555 typedef struct QsfValidates_s
00556 {
00557 QofErrorId error_state;
00558 const gchar *object_path;
00559 const gchar *map_path;
00562 GHashTable *object_table;
00565 GHashTable *map_table;
00566
00569 gint valid_object_count;
00572 gint map_calculated_count;
00575 gint qof_registered_count;
00578 guint incoming_count;
00579 } QsfValidator;
00580
00586 gint
00587 qsf_compare_tag_strings (const xmlChar * node_name,
00588 gchar * tag_name);
00589
00595 gint
00596 qsf_strings_equal (const xmlChar * node_name, gchar * tag_name);
00597
00603 gint
00604 qsf_is_element (xmlNodePtr a, xmlNsPtr ns, gchar * c);
00605
00611 gint
00612 qsf_check_tag (QsfParam * params, gchar * qof_type);
00613
00620 void
00621 qsf_object_validation_handler (xmlNodePtr child, xmlNsPtr ns,
00622 QsfValidator * valid);
00623
00639 gboolean
00640 qsf_is_valid (const gchar * schema_dir,
00641 const gchar * schema_filename, xmlDocPtr doc);
00642
00649 GList **qsf_map_prepare_list (GList ** maps);
00650
00674 typedef void (*QsfNodeCB) (xmlNodePtr, xmlNsPtr, QsfParam *);
00681 typedef void (*QsfValidCB) (xmlNodePtr, xmlNsPtr, QsfValidator *);
00686 struct QsfNodeIterate
00687 {
00688 QsfNodeCB *fcn;
00689 QsfValidCB *v_fcn;
00690 xmlNsPtr ns;
00691 };
00692
00712 gboolean is_qsf_object_be (QsfParam * params);
00713
00733 gboolean is_qsf_object (const gchar * path);
00734
00750 gboolean
00751 is_our_qsf_object_be (QsfParam * params);
00752
00768 gboolean is_our_qsf_object (const gchar * path);
00769
00782 gboolean is_qsf_map_be (QsfParam * params);
00783
00802 gboolean is_qsf_map (const gchar * path);
00803
00821 gboolean
00822 is_qsf_object_with_map_be (gchar * map_path, QsfParam * params);
00823
00840 gboolean
00841 is_qsf_object_with_map (const gchar * path, gchar * map_file);
00842
00852 void qsf_book_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
00853 QsfParam * params);
00854
00867 KvpValue *
00868 string_to_kvp_value (const gchar * content, KvpValueType type);
00869
00876 void
00877 qsf_valid_foreach (xmlNodePtr parent, QsfValidCB cb,
00878 struct QsfNodeIterate *qsfiter,
00879 QsfValidator * valid);
00880
00886 void
00887 qsf_node_foreach (xmlNodePtr parent, QsfNodeCB cb,
00888 struct QsfNodeIterate *qsfiter,
00889 QsfParam * params);
00890
00906 xmlDocPtr
00907 qsf_object_convert (xmlDocPtr mapDoc, xmlNodePtr qsf_root,
00908 QsfParam * params);
00909
00915 void
00916 qsf_object_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
00917 QsfParam * params);
00918
00922 #endif