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,
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"
102 #define QSF_OBJECT_COUNT "count"
104 #define QSF_XML_VERSION "1.0"
124 #define QSF_OBJECT_KVP "path"
125 
126 #define QSF_OBJECT_VALUE "value"
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 {
459 
466 typedef struct QsfMetadata_s
467 {
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;
512  gint foreach_limit;
516  QofBackend *be;
518  gboolean knowntype;
526  QofBook *book;
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;
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;
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 */