xml-basic-0.1.1.2: Basics for XML/HTML representation and processing

Text.XML.Basic.Character

Description

All kinds of representations of a character in XML combined in one type. Note that an entity can in principle represent a large text, thus an "XML character" might actually be a text. However the standard entities consist of one character. In contrast to our representation, HaXml uses Unicode substrings instead of Unicode characters, which is certainly more efficient for common XML texts that contain mainly Unicode text and only few references. However our representation is unique, whereas HaXmls may represent a text as abc,def or abcdef.

Synopsis

Documentation

data T Source

Instances

Eq T 
Show T 
C T 

toUnicode :: T -> Exceptional String CharSource

If a reference cannot be resolved then an Exception constructor with an error message is returned.

toUnicodeOrFormat :: T -> ShowSSource

If a reference cannot be resolved then a reference string is returned.

asciiFromUnicode :: Char -> TSource

Convert unicode character to XML Char, where Unicode constructor is only used for ASCII characters. This is achieved by the following decision: If there is a entity reference, use this. If it is ASCII, represent it as Char. Otherwise use a character reference.

minimalRefFromUnicode :: Char -> TSource

Generate XML character from Unicode character with minimal use of references. The only references used are the XML entity references ', ", &, <, >.

reduceRef :: T -> TSource

Reduce the use of references. Represent as much as possible characters as Unicode characters, that is, using the Unicode constructor.

reduceRefGen :: Map String Char -> T -> TSource

try to convert a References to equivalent Unicode characters

switchUnicodeRuns :: (String -> a) -> (Int -> a) -> (String -> a) -> [T] -> [a]Source