In most cases, the preferred way to create an XML document is to
create a Prolog tree of
element(Name, Attributes, Content)
terms and call xml_write/3
to write this to a stream. There are some exceptions where one might not
want to pay the price of the intermediate representation. For these
cases, this library contains building blocks for emitting markup data.
The quote funtions return a version of the input text into one that
contains entities for characters that need to be escaped. These are the
XML meta characters and the characters that cannot be expressed by the
document encoding. Therefore these predicates accept an encoding
argument. Accepted values are
Versions with two arguments are provided for backward compatibility,
making the safe
ascii encoding assumption.
- xml_quote_attribute(+In, -Quoted, +Encoding)
- Map the characters that may not appear in XML attributes to entities.
Currently these are
<>&".4Older versions also mapped
'. Characters that cannot represented in Encoding are mapped to XML character entities.
- xml_quote_attribute(+In, -Quoted)
- Backward compatibility version for xml_quote_attribute/3.
- xml_quote_cdata(+In, -Quoted, +Encoding)
- Very similar to xml_quote_attribute/3, but does not quote the single- and double-quotes.
- xml_quote_cdata(+In, -Quoted)
- Backward compatibility version for xml_quote_cdata/3.
- xml_name(+In, +Encoding)
- Succeed if In is an atom or string that satisfies the rules for a valid XML element or attribute name. As with the other predicates in this group, if Encoding cannot represent one of the characters, this function fails. Character classification is