12 releases (7 breaking)
0.11.0 | Jun 15, 2024 |
---|---|
0.10.0 | Mar 16, 2024 |
0.9.1 | Jan 25, 2023 |
0.8.2 | Dec 17, 2022 |
0.4.0 | Aug 18, 2021 |
#393 in Rust patterns
71,048 downloads per month
Used in 36 crates
(3 directly)
55KB
1.5K
SLoC
rxml_validation
— Utilities for validating strings against specific XML productions
This crate is an infrastructure/plumbing crate for the rxml
and rxml_proc
crates. It provides utility functions to validate that strings conform to the CData, Name and NCName grammars described in the XML 1.0 specification.
Please see the rxml and rxml_proc crates for more information.
lib.rs
:
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.
Dependencies
~110KB