XML has 5 pre-defined character entities which we should be able to encode and decode. These are:
& -> &
" => "
< => <
> => >
' => '
Thus, when serializing a &str or String or similar, if any of these characters occurs, we should replace them in the output. When deserializing, there are typically three possible target types:
&str: we should make sure the input string does not contain entities, and yield an error (or panic? I forget what serde does, but I guess we should copy its behavior) if it does
String: decode the entity before initializing the output type
Cow<_, 'str>: yield a Cow::Borrowed if the input string does not contain entities, Cow::Owned if it does
(Additionally a DTD may define custom entities in the XML header/prolog. This is something to keep in mind for the design but let's skip this feature for now -- as I understand it, it's not heavily used.)
XML has 5 pre-defined character entities which we should be able to encode and decode. These are:
&
->&
"
=>"
<
=><
>
=>>
'
=>'
Thus, when serializing a
&str
orString
or similar, if any of these characters occurs, we should replace them in the output. When deserializing, there are typically three possible target types:&str
: we should make sure the input string does not contain entities, and yield an error (or panic? I forget what serde does, but I guess we should copy its behavior) if it doesString
: decode the entity before initializing the output typeCow<_, 'str>
: yield aCow::Borrowed
if the input string does not contain entities,Cow::Owned
if it does(Additionally a DTD may define custom entities in the XML header/prolog. This is something to keep in mind for the design but let's skip this feature for now -- as I understand it, it's not heavily used.)