object
xml
ï
Bi-directional XML parser.
logtalk_load(xml_parser(loader))
static, context_switching_calls
On-line documentation: https://binding-time.co.uk/index.php/Parsing_XML_with_Prolog
Compliance: This XML parser supports a subset of XML suitable for XML Data and Worldwide Web applications. It is neither as strict nor as comprehensive as the XML 1.0 Specification mandates.
Compliance-strictness: It is not as strict, because, while the specification must eliminate ambiguities, not all errors need to be regarded as faults, and some reasonable examples of real XML usage would have to be rejected if they were.
Compliance-comprehensive: It is not as comprehensive, because, where the XML specification makes provision for more or less complete DTDs to be provided as part of a document, xml.pl actions the local definition of ENTITIES only. Other DTD extensions are treated as commentary.
Bi-directional conversions: Conversions are not fully symmetrical as weaker XML is accepted than can be generated. Notably, in-bound (Codes -> Document) parsing does not require strictly well-formed XML. If Codes does not represent well-formed XML, Document is instantiated to the term
malformed(<attributes>,<content>)
.
Public predicatesï
parse/2
ï
Parses a list of character codes to/from a data structure of the form xml(<atts>,<content>)
.
static
parse(Codes,Document)
parse(+list(character_code),?nonvar)
- zero_or_one
parse(?list(character_code),+nonvar)
- zero_or_one
parse/3
ï
Parses a list of character codes to/from a data structure of the form xml(<atts>,<content>)
using the given list of options.
static
parse(Options,Codes,Document)
parse(++list(compound),+list(character_code),?nonvar)
- zero_or_one
parse(++list(compound),?list(character_code),+nonvar)
- zero_or_one
extended_characters(Boolean)
option: Use the extended character entities for XHTML (defaulttrue
).
format(Boolean)
option: For parsing, strip layouts when no character data appears between elements (defaulttrue
). For generating, indent the element content (defaulttrue
).
remove_attribute_prefixes(Boolean)
option: Remove namespace prefixes from attributes when itâs the same as the prefix of the parent element (defaultfalse
).
allow_ampersand(Boolean)
option: Allow unescaped ampersand characters (&) to occur in PCDATA (defaultfalse
).
subterm/2
ï
Unifies Subterm
with a sub-term of XMLTerm
. Note that XMLTerm
is a sub-term of itself.
static
subterm(XMLTerm,Subterm)
subterm(+nonvar,?nonvar)
- zero_or_one
pp/1
ï
Pretty prints a XML document on the current output stream.
static
pp(XMLDocument)
pp(+nonvar)
- zero_or_one
Protected predicatesï
(no local declarations; see entity ancestors if any)
Private predicatesï
xml_to_document/3
ï
Translates the list of character codes XML
into the Prolog term Document
. Options
is a list of terms controlling the treatment of layout characters and character entities.
static
xml_to_document(Options,XML,Document)
xml_to_document(+nonvar,+nonvar,?nonvar)
- zero_or_one
empty_map/1
ï
True if Map
is a null map.
static
empty_map(Map)
empty_map(?nonvar)
- zero_or_one
map_member/3
ï
True if Map
is a ordered map structure which records the pair Key-Data
. Key
must be ground.
static
map_member(Key,Map,Data)
map_member(+nonvar,+nonvar,?nonvar)
- zero_or_one
map_store/4
ï
True if Map0
is an ordered map structure, Key
must be ground, and Map1
is identical to Map0
except that the pair Key-Data
is recorded by Map1
.
static
map_store(Map0,Key,Data,Map1)
map_store(+nonvar,+nonvar,+nonvar,?nonvar)
- zero_or_one
pp_string/1
ï
Prints String
onto the current output stream. If String
contains only 7-bit chars it is printed in shorthand quoted format, otherwise it is written as a list.
static
pp_string(String)
pp_string(+nonvar)
- zero_or_one
fault/5
ï
Identifies SubTerm
as a sub-term of Term
which cannot be serialized after Indentation
. Message
is an atom naming the type of error; Path
is a string encoding a list of SubTerm
âs ancestor elements in the form <tag>{(id)}*
where <tag>
is the element tag and <id>
is the value of any attribute _named_ id
.
static
fault(Term,Indentation,SubTerm,Path,Message)
fault(+nonvar,+nonvar,?nonvar,?nonvar,?nonvar)
- zero_or_one
exception/4
ï
Hook to raise an exception to be raised in respect of a fault in the XML Term Document
.
static
exception(Message,Document,Culprit,Path)
exception(+atom,+nonvar,+nonvar,+nonvar)
- one
document_generation//2
ï
DCG generating Document as a list of character codes. Format
is true|false defining whether layouts, to provide indentation, should be added between the element content of the resultant âstringâ. Note that formatting is disabled for elements that are interspersed with pcdata/1
terms, such as XHTMLâs âinlineâ elements. Also, Format
is over-ridden, for an individual element, by an explicit 'xml:space'="preserve"
attribute.
static
document_generation(Format,Document)
document_generation(+nonvar,+nonvar)
- zero_or_one
pcdata_7bit//1
ï
Represents the ASCII character set in its simplest format, using the character entities &
, "
, <
, and >
which are common to both XML and HTML. The numeric entity '
is used in place of '
because browsers donât recognize it in HTML.
static
pcdata_7bit(Code)
pcdata_7bit(?nonvar)
- zero_or_one
character_data_format/3
ï
Holds when Format0
and Format1
are the statuses of XML formatting before and after Codes
- which may be null.
static
character_data_format(Codes,Format0,Format1)
character_data_format(+nonvar,+nonvar,?nonvar)
- zero_or_one
cdata_generation//1
ï
Holds when Format0
and Format1
are the statuses of XML formatting before and after Codes
- which may be null.
static
cdata_generation(Codes)
cdata_generation(+list)
- zero_or_one
Operatorsï
(none)