back to XmlBlob main page
XmlBlob support available in spatialite_gui
You are required to download this collection of XML samples in order to follow this practical example.A pre-build executable of spatialite_gui 1.6.1-beta (win-x86) fully supporting XmlBlob and XPath is available for download.
Linux users can easily build their own executables starting from the sources available on the Fossil repository.
Credits: all the ows, sensors and metadata samples were taken from here
A new GUI tool is available, allowing to import one (or more) XmlDocuments into the DB in the simplest and painless way.
You can activate this tool from the menu or from the toolbar indifferently.
Using the XML Import tool you can import a single document or a whole folder at once. You can eventually check the XML Validation at the same time. A new import table can be created on-the-fly, or you can continue appending further documents into an already existing table. In this first step you are required to import all XmlDocuments contained into the books folder by applying exactly the settings shown on the side figure. |
As you can easily check a new table has been created, and all XmlDocuments from the books folder have been imported as XmlBlob values.
All XmlBlobs are both well-formed and XML valid.
Now you can continue importing all XmlDocuments from the misc and sld-se-styles folders, using each time yet again the same identical settings as before.
Just another check; few points worth to be noticed:
- the strong size benefits deriving from storing compressed XmlBlobs are absolutely clear e.g. on the regioni_se.xml sample.
- you can right-click over some XmlBlob cell; a specialized context-menu will appear supporting several useful operations.
- the schema_uri column allows to quickly verify the SchemaURI initially used to perform the XML Schema Validation step.
The Blob Explorer tool allows to immediately visualize the XmlDocument stored into the corresponding XmlBlob.
You can eventually choose between the original and the nicely indented formats.
More advanced examples
You can now continue importing several further samples from the metadata, ows and sensors folders. Please note: many of these samples are well-formatted, but are not XML valid (i.e. the Schema validation could often fail for one reason or another). So in this case is surely advisable performing a simplest import, thus skipping the formal Schema validation step. |
You can anyway attempt to validate these XmlDocuments in a second time.
e.g. the inspire-data-example.xml sample can successfully pass a formal XML validation, as we'll see in the following steps:
SELECT XmlGetInternalSchemaURI(XmlTextFromBlob(xml_document)) FROM meta_test WHERE file_name = 'inspire-data-example.xml'; --- http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsdWe'll start first by retrieving the Schema URI internally defined within the XmlDocument itself.
UPDATE meta_test SET xml_document = XmlBlobSchemaValidate(xml_document, 'http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd'), schema_uri = 'http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd' WHERE pk_uid = 5;and finally we'll update the XmlBlob by performing a formal Schema validation; we'll update the schema_uri column as well, so to maintain a full consistency.
and this is the final result of the two-steps validation.
You could eventually perform a further approach, by importing all XmlDocuments from the ows folder by attempting an immediate XML validation.
As you can see, three samples were successfully imported but the other three failed.
This is because the XML validation step failed; let's now go discovering why this happened.
- the URL http://schemas.opengis.net/wcseo/1.0/wcsEOAll.xsd simply doesn't exist.
- a file named context.xsd doesn't exist into the sample folder.
Please note: in both cases the Schema cannot be loaded, and consequently the whole XML validation step then fails. - and finally the XmlDocument wms-cap.xml has no internal Schema URI declaration at all.
It's interesting to note that this XmlDocument actually contains an internal DTD (as you can check by yourself using any text editor).
Anyway the current implementation of XmlBlob strictly requires that an XML Schema has to be declared.
back to XmlBlob main page