Expand description
§Strongly-typed strings for use with XML 1.0 documents
This crate defines various string- and str-like types which represent pieces of text as they may occur in XML documents. These types are checked to contain only text which conforms to the respective grammar in the XML specifications.
This allows to carry information about the checking which already took place in the parser to the application, avoiding the need to execute checks multiple times.
This is a supplementary crate for rxml
. It is
factored out of the main crate to support
rxml_proc
, a crate of macros which allow
compile-time validation and typing of XML strings. All types defined in this
crate are re-exported in rxml
; if you depend on rxml
, you can use the
types from there directly.
If the std
feature is not enabled (it is enabled by default), this crate
can be used in no_std
environments.
§Type Overview
Name
andNameStr
represent theName
production and can be used for element and attribute names before namespace prefix expansion.NcName
andNcNameStr
represent theName
production but without a colon inside; they are used for localnames after prefix expansion and to carry the prefixes themselves.
§Construction
In general, values are constructed using the std::convert::TryInto
trait, from other string types or str
. Supported source types are:
String
(copies)compact_str::CompactString
(moves)str
(copies for all types except the slice types)
Note: If the compact_str
feature is not enabled, all string types use
the normal std::string::String
type instead.
In addition, converting from NcName
to Name
is possible without extra
checking and is thus possible through .into()
(and likewise for the
corresponding str types).
The inverse directions are only available through try_into
.
§When to use rxml_validation vs. rxml?
You should use this crate (rxml_validation
) whenever you only need to
validate strings against rules present in XML, without actually parsing or
serialising XML data. In that case, this crate is a much lighter choice and
it can be used in no_std
environments.
Modules§
- selectors
- Constants and Utilities for matching ranges of codepoints
Structs§
- Name
std
- String which conforms to the Name production of XML 1.0.
- NameStr
- str which conforms to the Name production of XML 1.0.
- NcName
std
- String which conforms to the NcName production of Namespaces in XML 1.0.
- NcName
Str - str which conforms to the NcName production of Namespaces in XML 1.0.
Enums§
- Error
- Error condition from validating an XML string.
Functions§
- validate_
cdata - Check whether a str is valid XML 1.0 CData.
- validate_
name - Check whether a str is a valid XML 1.0 Name
- validate_
ncname - Check whether a str is a valid XML 1.0 Name, without colons.
Type Aliases§
- Compact
String std
- Type alias to access the inner type used for
Name
andNcName
irrespective of feature flags.