QOF: qsf-xml.h Source File

QOF 0.7.5

qsf-xml.h
Go to the documentation of this file.
1 /*****************************************************************
2 * qsf-xml.h
3 *
4 * Fri Nov 26 19:29:47 2004
5 * Copyright 2004,2005,2006 Neil Williams <linux@codehelp.co.uk>
6 *
7 ****************************************************************/
8 /*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 */
23
24 #ifndef QSF_XML_H
25 #define QSF_XML_H
26
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <regex.h>
35 #include <time.h>
36 #include "qof.h"
37
38 #include <libintl.h>
39 #define _(String) dgettext (GETTEXT_PACKAGE, String)
40
41 typedef enum
42 {
44 QSF_UNDEF = 0,
46 IS_QSF_MAP,
48 IS_QSF_OBJ,
50 HAVE_QSF_MAP,
52 OUR_QSF_OBJ,
53 } QsfType;
54
63 typedef struct QsfObject_s
64 {
65 GHashTable *parameters;
66 QofIdType object_type;
67 gint object_count;
68 } QsfObject;
69
70 #define QSF_QOF_VERSION QOF_OBJECT_VERSION
78 #define QSF_ROOT_TAG "qof-qsf"
79
84 #define QSF_DEFAULT_NS "http://qof.sourceforge.net/"
85
88 #define QSF_DATE_LENGTH MAX_DATE_LENGTH
89
91 #define QSF_BOOK_TAG "book"
92
94 #define QSF_BOOK_GUID "book-guid"
95
96 #define QSF_BOOK_COUNT "count"
97
98 #define QSF_OBJECT_TAG "object"
99
100 #define QSF_OBJECT_TYPE "type"
101
102 #define QSF_OBJECT_COUNT "count"
103
104 #define QSF_XML_VERSION "1.0"
105
124 #define QSF_OBJECT_KVP "path"
125
126 #define QSF_OBJECT_VALUE "value"
127
133 #define MAP_ROOT_TAG "qsf-map"
134
144 #define MAP_DEFINITION_TAG "definition"
145
151 #define MAP_DEFINE_TAG "define"
152
155 #define MAP_ITERATE_ATTR "foreach"
156
226 #define MAP_DEFAULT_TAG "default"
227
237 #define MAP_OBJECT_TAG "object"
238
248 #define MAP_CALCULATE_TAG "calculate"
249
257 #define MAP_QOF_VERSION "qof_version"
258
267 #define MAP_NAME_ATTR "name"
268
276 #define MAP_TYPE_ATTR "type"
277
286 #define MAP_VALUE_ATTR "value"
287
290 #define MAP_OBJECT_ATTR "object"
291
300 #define MAP_E_TYPE "e_type"
301
304 #define MAP_ENUM_TYPE "enum"
305
307 #define QSF_BOOLEAN_DEFAULT "boolean"
308
319 #define QSF_CONDITIONAL "if"
320
331 #define QSF_CONDITIONAL_SET "set"
332
355 #define QSF_CONDITIONAL_ELSE "else"
356
363 #define QSF_OPTION "option"
364
373 #define QSF_FORMATTING_OPTION "format"
374
411 #define QSF_XSD_TIME QOF_UTC_DATE_FORMAT
412
414 #define QSF_XML_BOOLEAN_TEST "true"
415
417 #define QSF_OBJECT_SCHEMA "qsf-object.xsd.xml"
418
420 #define QSF_MAP_SCHEMA "qsf-map.xsd.xml"
421
443 typedef enum
444 {
446 QSF_NO_OBJECT = 0,
450 QSF_DEFINED_OBJECT,
453 QSF_REGISTERED_OBJECT,
455 QSF_CALCULATED_OBJECT,
457 QSF_INVALID_OBJECT
458 } QsfStatus;
459
466 typedef struct QsfMetadata_s
467 {
469 QsfType file_type;
471 QsfObject *object_set;
473 gint count;
475 GList *qsf_object_list;
477 GSList *qsf_sequence;
479 GList *referenceList;
481 GHashTable *qsf_parameter_hash, *qsf_define_hash;
482 GHashTable *qsf_calculate_hash, *qsf_default_hash;
484 GSList *supported_types;
486 xmlDocPtr input_doc;
488 xmlDocPtr output_doc;
490 xmlNodePtr child_node;
492 xmlNodePtr convert_node;
494 xmlNodePtr param_node;
496 xmlNodePtr output_node;
498 xmlNodePtr output_root;
500 xmlNodePtr book_node;
502 xmlNodePtr lister;
504 xmlNsPtr qsf_ns, map_ns;
506 const gchar *qof_type;
508 QofIdType qof_obj_type;
510 QofIdType qof_foreach;
512 gint foreach_limit;
514 QofEntity *qsf_ent;
516 QofBackend *be;
518 gboolean knowntype;
520 QofParam *qof_param;
526 QofBook *book;
528 gint boolean_calculation_done;
530 gchar *filepath;
532 gchar *map_path;
534 gchar *full_kvp_path;
536 gint64 use_gz_level;
542 GList *map_files;
544 const gchar *encoding;
546 gint64 convert;
547 QofErrorId err_nomap, err_overflow;
548 } QsfParam;
549
555 typedef struct QsfValidates_s
556 {
557 QofErrorId error_state;
558 const gchar *object_path;
559 const gchar *map_path;
562 GHashTable *object_table;
565 GHashTable *map_table;
566 /* Need to match object names, not just counts. */
569 gint valid_object_count;
572 gint map_calculated_count;
575 gint qof_registered_count;
578 guint incoming_count;
579 } QsfValidator;
580
586 gint
587 qsf_compare_tag_strings (const xmlChar * node_name,
588 gchar * tag_name);
589
595 gint
596 qsf_strings_equal (const xmlChar * node_name, gchar * tag_name);
597
603 gint
604 qsf_is_element (xmlNodePtr a, xmlNsPtr ns, gchar * c);
605
611 gint
612 qsf_check_tag (QsfParam * params, gchar * qof_type);
613
620 void
621 qsf_object_validation_handler (xmlNodePtr child, xmlNsPtr ns,
622 QsfValidator * valid);
623
639 gboolean
640 qsf_is_valid (const gchar * schema_dir,
641 const gchar * schema_filename, xmlDocPtr doc);
642
649 GList **qsf_map_prepare_list (GList ** maps);
650
674 typedef void (*QsfNodeCB) (xmlNodePtr, xmlNsPtr, QsfParam *);
681 typedef void (*QsfValidCB) (xmlNodePtr, xmlNsPtr, QsfValidator *);
686 struct QsfNodeIterate
687 {
688 QsfNodeCB *fcn;
689 QsfValidCB *v_fcn;
690 xmlNsPtr ns;
691 };
692
712 gboolean is_qsf_object_be (QsfParam * params);
713
733 gboolean is_qsf_object (const gchar * path);
734
750 gboolean
751 is_our_qsf_object_be (QsfParam * params);
752
768 gboolean is_our_qsf_object (const gchar * path);
769
782 gboolean is_qsf_map_be (QsfParam * params);
783
802 gboolean is_qsf_map (const gchar * path);
803
821 gboolean
822 is_qsf_object_with_map_be (gchar * map_path, QsfParam * params);
823
840 gboolean
841 is_qsf_object_with_map (const gchar * path, gchar * map_file);
842
852 void qsf_book_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
853 QsfParam * params);
854
867 KvpValue *
868 string_to_kvp_value (const gchar * content, KvpValueType type);
869
876 void
877 qsf_valid_foreach (xmlNodePtr parent, QsfValidCB cb,
878 struct QsfNodeIterate *qsfiter,
879 QsfValidator * valid);
880
886 void
887 qsf_node_foreach (xmlNodePtr parent, QsfNodeCB cb,
888 struct QsfNodeIterate *qsfiter,
889 QsfParam * params);
890
906 xmlDocPtr
907 qsf_object_convert (xmlDocPtr mapDoc, xmlNodePtr qsf_root,
908 QsfParam * params);
909
915 void
916 qsf_object_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
917 QsfParam * params);
918
922 #endif /* QSF_XML_H */
QsfMetadata_s
QSF Parameters.
Definition: qsf-xml.h:469
QSF_NO_OBJECT
Definition: qsf-xml.h:449
QsfMetadata_s::qsf_ns
xmlNsPtr qsf_ns
Definition: qsf-xml.h:507
QsfValidates_s::map_calculated_count
gint map_calculated_count
Definition: qsf-xml.h:575
QsfValidator
struct QsfValidates_s QsfValidator
Validation metadata.
QsfMetadata_s::full_kvp_path
gchar * full_kvp_path
Definition: qsf-xml.h:537
qsf_object_validation_handler
void qsf_object_validation_handler(xmlNodePtr child, xmlNsPtr ns, QsfValidator *valid)
Checks all incoming objects for QOF registration.
Definition: qsf-xml.c:134
qsf_check_tag
gint qsf_check_tag(QsfParam *params, gchar *qof_type)
shorthand function
Definition: qsf-xml.c:69
QofIdType
const gchar * QofIdType
Definition: qofid.h:81
QSF_REGISTERED_OBJECT
Definition: qsf-xml.h:456
is_qsf_object_with_map
gboolean is_qsf_object_with_map(const gchar *path, gchar *map_file)
Validate a QSF file and a selected QSF map.
Definition: qsf-xml-map.c:290
_QofParam
Definition: qofclass.h:195
is_qsf_object
gboolean is_qsf_object(const gchar *path)
Validate a QSF file and identify a suitable QSF map.
Definition: qsf-xml.c:219
HAVE_QSF_MAP
Definition: qsf-xml.h:50
QsfValidates_s
Validation metadata.
Definition: qsf-xml.h:558
QsfValidates_s::map_table
GHashTable * map_table
Definition: qsf-xml.h:568
KvpValueType
KvpValueType
possible types in the union KvpValue
Definition: kvpframe.h:87
QofEntity_s
Definition: qofid.h:147
QsfMetadata_s::count
gint count
Definition: qsf-xml.h:476
qsf_valid_foreach
void qsf_valid_foreach(xmlNodePtr parent, QsfValidCB cb, struct QsfNodeIterate *qsfiter, QsfValidator *valid)
Definition: qsf-xml.c:102
QsfMetadata_s::file_type
QsfType file_type
Definition: qsf-xml.h:472
QsfMetadata_s::knowntype
gboolean knowntype
Definition: qsf-xml.h:521
qsf_is_valid
gboolean qsf_is_valid(const gchar *schema_dir, const gchar *schema_filename, xmlDocPtr doc)
Compares an xmlDoc in memory against the schema file.
Definition: qsf-xml.c:75
QofErrorId
gint32 QofErrorId
The ID of this error.
Definition: qofbackend.h:54
QsfMetadata_s::qsf_ent
QofEntity * qsf_ent
Definition: qsf-xml.h:517
is_qsf_object_be
gboolean is_qsf_object_be(QsfParam *params)
Validate a QSF file and identify a suitable QSF map.
Definition: qsf-xml.c:299
QsfMetadata_s::boolean_calculation_done
gint boolean_calculation_done
Definition: qsf-xml.h:531
QSF_DEFINED_OBJECT
Definition: qsf-xml.h:453
QsfMetadata_s::be
QofBackend * be
Definition: qsf-xml.h:519
OUR_QSF_OBJ
Definition: qsf-xml.h:52
QsfMetadata_s::qsf_sequence
GSList * qsf_sequence
Definition: qsf-xml.h:480
QsfMetadata_s::foreach_limit
gint foreach_limit
Definition: qsf-xml.h:515
qsf_strings_equal
gint qsf_strings_equal(const xmlChar *node_name, gchar *tag_name)
shorthand function
Definition: qsf-xml.c:45
qsf_compare_tag_strings
gint qsf_compare_tag_strings(const xmlChar *node_name, gchar *tag_name)
shorthand function
Definition: qsf-xml.c:39
QsfMetadata_s::encoding
const gchar * encoding
Definition: qsf-xml.h:547
KvpValue
struct _KvpValue KvpValue
Definition: kvpframe.h:78
is_our_qsf_object
gboolean is_our_qsf_object(const gchar *path)
Validate a QSF file.
Definition: qsf-xml.c:180
QsfMetadata_s::input_doc
xmlDocPtr input_doc
Definition: qsf-xml.h:489
IS_QSF_MAP
Definition: qsf-xml.h:46
QsfNodeIterate
One iterator, two typedefs.
Definition: qsf-xml.h:689
QsfMetadata_s::qof_foreach
QofIdType qof_foreach
Definition: qsf-xml.h:513
QsfMetadata_s::map_path
gchar * map_path
Definition: qsf-xml.h:535
qsf_map_prepare_list
GList ** qsf_map_prepare_list(GList **maps)
Prepare the default list of maps.
Definition: qsf-backend.c:167
QsfMetadata_s::qsf_object_list
GList * qsf_object_list
Definition: qsf-xml.h:478
QsfValidates_s::qof_registered_count
gint qof_registered_count
Definition: qsf-xml.h:578
IS_QSF_OBJ
Definition: qsf-xml.h:48
QsfMetadata_s::convert_node
xmlNodePtr convert_node
Definition: qsf-xml.h:495
QsfStatus
QsfStatus
Status of various object during mapping.
Definition: qsf-xml.h:446
QsfMetadata_s::supported_types
GSList * supported_types
Definition: qsf-xml.h:487
qsf_node_foreach
void qsf_node_foreach(xmlNodePtr parent, QsfNodeCB cb, struct QsfNodeIterate *qsfiter, QsfParam *params)
Definition: qsf-xml.c:116
QsfMetadata_s::lister
xmlNodePtr lister
Definition: qsf-xml.h:505
QsfType
QsfType
Definition: qsf-xml.h:41
string_to_kvp_value
KvpValue * string_to_kvp_value(const gchar *content, KvpValueType type)
Convert a string value into KvpValue.
Definition: qsf-backend.c:1223
QsfMetadata_s::child_node
xmlNodePtr child_node
Definition: qsf-xml.h:493
QsfMetadata_s::convert
gint64 convert
Definition: qsf-xml.h:549
QsfValidates_s::valid_object_count
gint valid_object_count
Definition: qsf-xml.h:572
QsfMetadata_s::referenceList
GList * referenceList
Definition: qsf-xml.h:482
QsfMetadata_s::use_gz_level
gint64 use_gz_level
Definition: qsf-xml.h:539
QsfMetadata_s::param_node
xmlNodePtr param_node
Definition: qsf-xml.h:497
QsfMetadata_s::book_node
xmlNodePtr book_node
Definition: qsf-xml.h:503
is_qsf_object_with_map_be
gboolean is_qsf_object_with_map_be(gchar *map_path, QsfParam *params)
Validate a QSF file and a selected QSF map.
Definition: qsf-xml-map.c:240
QsfMetadata_s::qof_param
QofParam * qof_param
Definition: qsf-xml.h:523
QsfMetadata_s::qsf_parameter_hash
GHashTable * qsf_parameter_hash
Definition: qsf-xml.h:484
QsfNodeCB
void(* QsfNodeCB)(xmlNodePtr, xmlNsPtr, QsfParam *)
map and qsf object callback
Definition: qsf-xml.h:677
QsfObject
struct QsfObject_s QsfObject
Holds a description of the QofObject.
QsfMetadata_s::book
QofBook * book
Definition: qsf-xml.h:529
QSF_INVALID_OBJECT
Definition: qsf-xml.h:460
is_qsf_map_be
gboolean is_qsf_map_be(QsfParam *params)
Validate a QSF map file.
Definition: qsf-xml-map.c:320
is_qsf_map
gboolean is_qsf_map(const gchar *path)
Validate a QSF map file.
Definition: qsf-xml-map.c:372
QsfMetadata_s::map_files
GList * map_files
Definition: qsf-xml.h:545
QsfMetadata_s::qof_obj_type
QofIdType qof_obj_type
Definition: qsf-xml.h:511
QsfValidates_s::incoming_count
guint incoming_count
Definition: qsf-xml.h:581
is_our_qsf_object_be
gboolean is_our_qsf_object_be(QsfParam *params)
Validate a QSF file and determine type.
Definition: qsf-xml.c:243
qsf_is_element
gint qsf_is_element(xmlNodePtr a, xmlNsPtr ns, gchar *c)
shorthand function
Definition: qsf-xml.c:55
QsfMetadata_s::output_node
xmlNodePtr output_node
Definition: qsf-xml.h:499
QsfMetadata_s::filepath
gchar * filepath
Definition: qsf-xml.h:533
QsfObject_s
Holds a description of the QofObject.
Definition: qsf-xml.h:63
_QofBook
Definition: qofbook-p.h:48
QsfMetadata_s::qof_type
const gchar * qof_type
Definition: qsf-xml.h:509
qsf_object_convert
xmlDocPtr qsf_object_convert(xmlDocPtr mapDoc, xmlNodePtr qsf_root, QsfParam *params)
Convert between QSF objects.
Definition: qsf-xml-map.c:954
qsf_book_node_handler
void qsf_book_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, QsfParam *params)
Book and book-guid node handler.
Definition: qsf-xml.c:424
QsfMetadata_s::output_root
xmlNodePtr output_root
Definition: qsf-xml.h:501
QsfValidates_s::object_table
GHashTable * object_table
Definition: qsf-xml.h:565
QSF_CALCULATED_OBJECT
Definition: qsf-xml.h:458
QsfMetadata_s::object_set
QsfObject * object_set
Definition: qsf-xml.h:474
QsfParam
struct QsfMetadata_s QsfParam
QSF Parameters.
QsfMetadata_s::output_doc
xmlDocPtr output_doc
Definition: qsf-xml.h:491
qsf_object_node_handler
void qsf_object_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, QsfParam *params)
Definition: qsf-xml.c:385
QofBackend_s
Definition: qofbackend-p.h:283
QsfValidCB
void(* QsfValidCB)(xmlNodePtr, xmlNsPtr, QsfValidator *)
validator callback
Definition: qsf-xml.h:684
QSF_UNDEF
Definition: qsf-xml.h:44