Author(s): José Manuel Gómez Pérez.
Version: 0.1 (2003/12/1, 13:24:9 CET)
This package provides a language suitable for querying XML documents from a Prolog program. Constraint programming expresions can be included in order to prune search as soon as possible, i.e. upon constraint unsatisfability, improving efficiency. Also, facilities are offerd to improve search speed by transforming XML documents into Prolog programs, hence reducing search to just running the program and taking advantage of Prolog's indexing capabilities.
Queries in an XML document have a recursive tree structructure that permits to detail the search on the XML element sought, its attributes, and its children. As a suffix, a constraint programming expression can be added. Queries return value for the free variables included (in case of success), and checks whether the XML document structure matches that depicted by the query itself.
The operators introduced are described below:
product@val(product_name, "car")
, the first argument being the attribute name and the second its value. Any of them can be free variables, being possible to write queries like product@val(Name, "car")
, intended to find the 'Name' of attributes of element product whose value is the string "car".
Some examples of this query language (more can be found in the examples directory):
product@val(product_name,"car")::(quantity(X), 'time-left'(Y), negotiation::preference::price(Z)) with X * Z .>. Y
nitf::head::docdata::'doc-id'@val('id-string',"020918050")::(Y), body::'body.head'::abstract::p(X)
xml_path
)xml_path
)
Usage: xml_search(+Query, +Source, -Doc)
Query
against an XML document Source
. If the query is successful it retuns in Doc
the whole xml element(s) of the document that matched it.
+Query
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
+Source
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
-Doc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_parse(+Query, +Source, -Doc)
Query
against an XML document Source
. If the query is successful it retuns in Doc
the whole xml element(s) of the document that matched it. On the contrary as
xml_search/3
, the query can start at any level of the XML document, not necessarily at the root node.
+Query
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
+Source
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
-Doc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_parse_match(+Query, +Source, -Match)
Query
against an XML document Source
. If the query is successful it retuns in Doc
the exact subtree of the xml document that matched it. On the contrary as
'$xml_search_match/3
, the query can start at any level of the XML document, not necessarily at the root node.
+Query
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
+Source
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
-Match
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_search_match(+BasicQuery, +SourceDoc, -Match)
Query
against an XML document Source
. If the query is successful it retuns in Doc
the exact subtree of the xml document that matched it.
+BasicQuery
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
+SourceDoc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
-Match
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_index_query(+Query, -Id, -Match)
Query
against an XML document previously transformed into a Prolog program. Id
identifies the resulting document Match
, which is the exact match of the query against the XML document.
+Query
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
-Id
is an atom.
(basic_props:atm/1
)
-Match
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_index_to_file(SourceDoc, File)
SourceDoc
in a Prolog program which is output to file File
.
SourceDoc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
File
is an atom.
(basic_props:atm/1
)
Usage: xml_index(SourceDoc)
SourceDoc
in a Prolog program, generating the associated clauses, which are stored dynamically into the current process memory space.
SourceDoc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
Usage: xml_query(+Query, +Doc, -Match)
Doc
is compliant with respect to the query Query
expressed in the low level query language. The exact mapping of the query over the document is returned in Match
+Query
is a primitive XML query.
(xml_path_types:canonic_xml_query/1
)
+Doc
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
-Match
is either a XML attribute, a XML element or a line break.
(xml_path_types:canonic_xml_item/1
)
xml_path
)
Usage: canonic_xml_term(XMLTerm)
XMLTerm
is a term representing XML code in canonical form.
Usage: canonic_xml_item(XMLItem)
XMLItem
is either a XML attribute, a XML element or a line break.
Usage: tag_attrib(Att)
Att
is a XML attribute.
Usage: canonic_xml_query(Query)
Query
is a primitive XML query.
Usage: canonic_xml_subquery(SQuery)
SQuery
defines a XML subquery.
Go to the first, previous, next, last section, table of contents.