SpatiaLite  5.0.0
gg_xml.h
Go to the documentation of this file.
1 /*
2  gg_xml.h -- Gaia common support for XML documents
3 
4  version 5.0, 2020 August 1
5 
6  Author: Sandro Furieri a.furieri@lqt.it
7 
8  ------------------------------------------------------------------------------
9 
10  Version: MPL 1.1/GPL 2.0/LGPL 2.1
11 
12  The contents of this file are subject to the Mozilla Public License Version
13  1.1 (the "License"); you may not use this file except in compliance with
14  the License. You may obtain a copy of the License at
15  http://www.mozilla.org/MPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
19 for the specific language governing rights and limitations under the
20 License.
21 
22 The Original Code is the SpatiaLite library
23 
24 The Initial Developer of the Original Code is Alessandro Furieri
25 
26 Portions created by the Initial Developer are Copyright (C) 2008-2020
27 the Initial Developer. All Rights Reserved.
28 
29 Contributor(s):
30 
31 Alternatively, the contents of this file may be used under the terms of
32 either the GNU General Public License Version 2 or later (the "GPL"), or
33 the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
34 in which case the provisions of the GPL or the LGPL are applicable instead
35 of those above. If you wish to allow use of your version of this file only
36 under the terms of either the GPL or the LGPL, and not to allow others to
37 use your version of this file under the terms of the MPL, indicate your
38 decision by deleting the provisions above and replace them with the notice
39 and other provisions required by the GPL or the LGPL. If you do not delete
40 the provisions above, a recipient may use your version of this file under
41 the terms of any one of the MPL, the GPL or the LGPL.
42 
43 */
44 
45 
52 #ifndef _GG_XML_H
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 #define _GG_XML_H
55 #endif
56 
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61 
62 /* constant values for XmlBLOB */
63 
65 #define GAIA_XML_START 0x00
66 
67 #define GAIA_XML_END 0xDD
68 
69 #define GAIA_XML_HEADER 0xAC
70 
71 #define GAIA_XML_LEGACY_HEADER 0xAB
72 
73 #define GAIA_XML_SCHEMA 0xBA
74 
75 #define GAIA_XML_FILEID 0xCA
76 
77 #define GAIA_XML_PARENTID 0xDA
78 
79 #define GAIA_XML_NAME 0xDE
80 
81 #define GAIA_XML_TITLE 0xDB
82 
83 #define GAIA_XML_ABSTRACT 0xDC
84 
85 #define GAIA_XML_GEOMETRY 0xDD
86 
87 #define GAIA_XML_CRC32 0xBC
88 
89 #define GAIA_XML_PAYLOAD 0xCB
90 
91 /* bitmasks for XmlBLOB-FLAG */
92 
94 #define GAIA_XML_LITTLE_ENDIAN 0x01
95 
96 #define GAIA_XML_COMPRESSED 0x02
97 
98 #define GAIA_XML_VALIDATED 0x04
99 
100 #define GAIA_XML_ISO_METADATA 0x80
101 
102 #define GAIA_XML_SLD_SE_RASTER_STYLE 0x10
103 
104 #define GAIA_XML_SLD_SE_VECTOR_STYLE 0x40
105 
106 #define GAIA_XML_SLD_STYLE 0x48
107 
108 #define GAIA_XML_SVG 0x20
109 
110 #define GAIA_XML_GPX 0x08
111 
112 #define GAIA_XML_MAP_CONFIG 0x88
113 
114 
115 /* function prototypes */
116 
117 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
118 #ifdef ENABLE_LIBXML2 /* LIBXML2 enabled: supporting XML documents */
119 #endif
120 
130  GAIAGEO_DECLARE char *gaia_libxml2_version (void);
131 
156  GAIAGEO_DECLARE void gaiaXmlToBlob (const void *p_cache,
157  const unsigned char *xml, int xml_len,
158  int compressed, const char *schemaURI,
159  unsigned char **result, int *size,
160  char **parsing_errors,
161  char **schema_validation_errors);
162 
184  GAIAGEO_DECLARE char *gaiaXmlTextFromBlob (const unsigned char *blob,
185  int size, int indent);
186 
209  GAIAGEO_DECLARE void gaiaXmlFromBlob (const unsigned char *blob,
210  int size, int indent,
211  unsigned char **result,
212  int *res_size);
213 
227  GAIAGEO_DECLARE int gaiaIsValidXmlBlob (const unsigned char *blob,
228  int size);
229 
243  GAIAGEO_DECLARE int gaiaIsCompressedXmlBlob (const unsigned char *blob,
244  int size);
245 
259  GAIAGEO_DECLARE int gaiaIsIsoMetadataXmlBlob (const unsigned char *blob,
260  int size);
261 
275  GAIAGEO_DECLARE int gaiaIsSldSeVectorStyleXmlBlob (const unsigned char
276  *blob, int size);
277 
292  GAIAGEO_DECLARE int gaiaIsSldSeRasterStyleXmlBlob (const unsigned char
293  *blob, int size);
294 
309  GAIAGEO_DECLARE int gaiaIsSldStyleXmlBlob (const unsigned char
310  *blob, int size);
311 
326  GAIAGEO_DECLARE int gaiaIsMapConfigXmlBlob (const unsigned char
327  *blob, int size);
328 
342  GAIAGEO_DECLARE int gaiaIsSvgXmlBlob (const unsigned char *blob, int size);
343 
357  GAIAGEO_DECLARE int gaiaIsGpxXmlBlob (const unsigned char *blob, int size);
358 
375  GAIAGEO_DECLARE void gaiaXmlBlobCompression (const unsigned char *blob,
376  int in_size, int compressed,
377  unsigned char **result,
378  int *out_size);
379 
394  GAIAGEO_DECLARE int gaiaIsSchemaValidatedXmlBlob (const unsigned char
395  *blob, int size);
396 
406  GAIAGEO_DECLARE int gaiaXmlBlobGetDocumentSize (const unsigned char *blob,
407  int size);
408 
423  GAIAGEO_DECLARE char *gaiaXmlBlobGetSchemaURI (const unsigned char
424  *blob, int size);
425 
441  GAIAGEO_DECLARE char *gaiaXmlGetInternalSchemaURI (const void *p_cache,
442  const unsigned char
443  *xml, int xml_len);
444 
459  GAIAGEO_DECLARE char *gaiaXmlBlobGetFileId (const unsigned char
460  *blob, int size);
461 
476  GAIAGEO_DECLARE char *gaiaXmlBlobGetParentId (const unsigned char
477  *blob, int size);
478 
496  GAIAGEO_DECLARE int gaiaXmlBlobSetFileId (const void *p_cache,
497  const unsigned char *blob,
498  int size,
499  const char *identifier,
500  unsigned char **new_blob,
501  int *new_size);
502 
520  GAIAGEO_DECLARE int gaiaXmlBlobSetParentId (const void *p_cache,
521  const unsigned char *blob,
522  int size,
523  const char *identifier,
524  unsigned char **new_blob,
525  int *new_size);
526 
548  GAIAGEO_DECLARE int gaiaXmlBlobAddFileId (const void *p_cache,
549  const unsigned char *blob,
550  int size,
551  const char *identifier,
552  const char *ns_id,
553  const char *uri_id,
554  const char *ns_charstr,
555  const char *uri_charstr,
556  unsigned char **new_blob,
557  int *new_size);
558 
580  GAIAGEO_DECLARE int gaiaXmlBlobAddParentId (const void *p_cache,
581  const unsigned char *blob,
582  int size,
583  const char *identifier,
584  const char *ns_id,
585  const char *uri_id,
586  const char *ns_charstr,
587  const char *uri_charstr,
588  unsigned char **new_blob,
589  int *new_size);
590 
606  GAIAGEO_DECLARE char *gaiaXmlBlobGetName (const unsigned char
607  *blob, int size);
608 
624  GAIAGEO_DECLARE char *gaiaXmlBlobGetTitle (const unsigned char
625  *blob, int size);
626 
642  GAIAGEO_DECLARE char *gaiaXmlBlobGetAbstract (const unsigned char
643  *blob, int size);
644 
661  GAIAGEO_DECLARE void gaiaXmlBlobGetGeometry (const unsigned char
662  *blob, int size,
663  unsigned char **blob_geom,
664  int *blob_size);
665 
680  GAIAGEO_DECLARE gaiaGeomCollPtr gaiaXmlBlobMLineFromGPX (const unsigned
681  char *blob,
682  int size,
683  sqlite3 *
684  db_handle);
685 
698  GAIAGEO_DECLARE char *gaiaXmlBlobGetEncoding (const unsigned char
699  *blob, int size);
700 
715  GAIAGEO_DECLARE char *gaiaXmlBlobGetLastParseError (const void *p_cache);
716 
731  GAIAGEO_DECLARE char *gaiaXmlBlobGetLastValidateError (const void *p_cache);
732 
744  GAIAGEO_DECLARE int gaiaIsValidXPathExpression (const void *p_cache,
745  const char *xpath_expr);
746 
761  GAIAGEO_DECLARE char *gaiaXmlBlobGetLastXPathError (const void *p_cache);
762 
779  GAIAGEO_DECLARE int gaiaXmlLoad (const void *p_cache,
780  const char *path_or_url,
781  unsigned char **result, int *size,
782  char **parsing_errors);
783 
809  GAIAGEO_DECLARE int gaiaXmlStore (const unsigned char *blob, int size,
810  const char *path, int indent);
811 
812 #endif /* end LIBXML2: supporting XML documents */
813 
814 #ifdef __cplusplus
815 }
816 #endif
817 
818 #endif /* _GG_XML_H */
GAIAGEO_DECLARE void gaiaXmlBlobCompression(const unsigned char *blob, int in_size, int compressed, unsigned char **result, int *out_size)
Return another XmlBLOB buffer compressed / uncompressed.
GAIAGEO_DECLARE int gaiaIsSldSeVectorStyleXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not.
GAIAGEO_DECLARE int gaiaIsSvgXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain an SVG Symbol or not.
GAIAGEO_DECLARE int gaiaIsIsoMetadataXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain an ISO Metadata or not.
GAIAGEO_DECLARE char * gaiaXmlGetInternalSchemaURI(const void *p_cache, const unsigned char *xml, int xml_len)
Return the Internal SchemaURI from a valid XmlDocument.
GAIAGEO_DECLARE char * gaia_libxml2_version(void)
return the LIBXML2 version string
GAIAGEO_DECLARE int gaiaIsSldStyleXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain an SLD Style or not.
GAIAGEO_DECLARE char * gaiaXmlTextFromBlob(const unsigned char *blob, int size, int indent)
Extract an XMLDocument from within an XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaXmlBlobSetParentId(const void *p_cache, const unsigned char *blob, int size, const char *identifier, unsigned char **new_blob, int *new_size)
Return a new XmlBLOB (ISO Metadata) by replacing the ParentId value.
GAIAGEO_DECLARE int gaiaXmlLoad(const void *p_cache, const char *path_or_url, unsigned char **result, int *size, char **parsing_errors)
Load an external XML Document.
GAIAGEO_DECLARE int gaiaIsValidXmlBlob(const unsigned char *blob, int size)
Checks if a BLOB actually is a valid XmlBLOB buffer.
GAIAGEO_DECLARE void gaiaXmlBlobGetGeometry(const unsigned char *blob, int size, unsigned char **blob_geom, int *blob_size)
Return the Geometry buffer from a valid XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetLastParseError(const void *p_cache)
Return the most recent XML Parse error/warning (if any)
GAIAGEO_DECLARE char * gaiaXmlBlobGetName(const unsigned char *blob, int size)
Return the Name from a valid XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetLastValidateError(const void *p_cache)
Return the most recent XML Validate error/warning (if any)
GAIAGEO_DECLARE int gaiaXmlBlobAddFileId(const void *p_cache, const unsigned char *blob, int size, const char *identifier, const char *ns_id, const char *uri_id, const char *ns_charstr, const char *uri_charstr, unsigned char **new_blob, int *new_size)
Return a new XmlBLOB (ISO Metadata) by inserting a FileId value.
GAIAGEO_DECLARE int gaiaXmlBlobAddParentId(const void *p_cache, const unsigned char *blob, int size, const char *identifier, const char *ns_id, const char *uri_id, const char *ns_charstr, const char *uri_charstr, unsigned char **new_blob, int *new_size)
Return a new XmlBLOB (ISO Metadata) by inserting a ParentId value.
GAIAGEO_DECLARE char * gaiaXmlBlobGetEncoding(const unsigned char *blob, int size)
Return the Charset Encoding from a valid XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetTitle(const unsigned char *blob, int size)
Return the Title from a valid XmlBLOB buffer.
GAIAGEO_DECLARE void gaiaXmlToBlob(const void *p_cache, const unsigned char *xml, int xml_len, int compressed, const char *schemaURI, unsigned char **result, int *size, char **parsing_errors, char **schema_validation_errors)
Creates an XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaIsMapConfigXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain a MapConfig or not.
GAIAGEO_DECLARE int gaiaXmlStore(const unsigned char *blob, int size, const char *path, int indent)
Stores an external XML Document.
GAIAGEO_DECLARE char * gaiaXmlBlobGetSchemaURI(const unsigned char *blob, int size)
Return the SchemaURI from a valid XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaXmlBlobGetDocumentSize(const unsigned char *blob, int size)
Return the XMLDocument size (in bytes) from a valid XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetParentId(const unsigned char *blob, int size)
Return the ParentIdentifier from a valid XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaIsValidXPathExpression(const void *p_cache, const char *xpath_expr)
Checks if a Text string could be a valid XPathExpression.
GAIAGEO_DECLARE int gaiaIsSldSeRasterStyleXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain an SLD/SE Style or not.
GAIAGEO_DECLARE void gaiaXmlFromBlob(const unsigned char *blob, int size, int indent, unsigned char **result, int *res_size)
Extract an XMLDocument from within an XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaXmlBlobSetFileId(const void *p_cache, const unsigned char *blob, int size, const char *identifier, unsigned char **new_blob, int *new_size)
Return a new XmlBLOB (ISO Metadata) by replacing the FileId value.
GAIAGEO_DECLARE int gaiaIsSchemaValidatedXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer has successfully passed a formal Schema validation or not.
GAIAGEO_DECLARE gaiaGeomCollPtr gaiaXmlBlobMLineFromGPX(const unsigned char *blob, int size, sqlite3 *db_handle)
Return a MultiLinestring Geometry from a valid GPX XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetAbstract(const unsigned char *blob, int size)
Return the Abstract from a valid XmlBLOB buffer.
GAIAGEO_DECLARE int gaiaIsGpxXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer does contain a GPX document or not.
Container for OGC GEOMETRYCOLLECTION Geometry.
Definition: gg_structs.h:226
GAIAGEO_DECLARE int gaiaIsCompressedXmlBlob(const unsigned char *blob, int size)
Checks if a valid XmlBLOB buffer is compressed or not.
GAIAGEO_DECLARE char * gaiaXmlBlobGetFileId(const unsigned char *blob, int size)
Return the FileIdentifier from a valid XmlBLOB buffer.
GAIAGEO_DECLARE char * gaiaXmlBlobGetLastXPathError(const void *p_cache)
Return the most recent XPath error/warning (if any)