HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

  • Packagehxt-9.3.1.22
  • Exports113
  • LanguageHaskell2010
  • LicenceMIT
  • SourceXmlState.hs

Data Types

6 declarations
datadata XIOState us
#

state datatype consists of a system state and a user state the user state is not fixed

Instances1NFData
datadata XIOSysState
#

predefined system state data type with all components for the system functions, like trace, error handling, ...

Instances1NFData
typetype IOSArrow b c = IOStateArrow () b c
#

The arrow for stateful arrows with no user defined state

User State Manipulation

6 declarations
valuewithExtendedUserState
  1. :: s1
  2. -> IOStateArrow (s1, s0) b c
  3. -> IOStateArrow s0 b c
#

extend user state

Run an arrow with an extended user state component, The old component is stored together with a new one in a pair, the arrow is executed with this extended state, and the augmented state component is removed form the state when the arrow has finished its execution

valuewithOtherUserState :: s1 -> IOStateArrow s1 b c -> IOStateArrow s0 b c
#

change the type of user state

This conversion is useful, when running a state arrow with another structure of the user state, e.g. with () when executing some IO arrows

Run IO State arrows

1 declaration
valuerunX :: IOSArrow XmlTree c -> IO [c]
#

apply an IOSArrow to an empty root node with initialState () as initial state

the main entry point for running a state arrow with IO

when running runX f an empty XML root node is applied to f. usually f will start with a constant arrow (ignoring the input), e.g. a readDocument arrow.

for usage see examples with writeDocument

if input has to be feed into the arrow use runIOSLA like in runIOSLA f emptyX inputDoc

Global System State Configuration and Access

9 declarations

Error Handling

18 declarations

if error messages are collected by the error handler for processing these messages by the calling application, this arrow reads the stored messages and clears the error message store

Tracing

12 declarations
valuetraceValue :: Int -> (b -> String) -> IOStateArrow s b b
#

trace the current value transfered in a sequence of arrows.

The value is formated by a string conversion function. This is a substitute for the old and less general traceString function

Document Base

6 declarations

set the default base URI, if parameter is null, the system base ( file:///<cwd>/ ) is used, else the parameter, must be called before any document is read

URI Manipulation

10 declarations

Mime Type Handling

3 declarations

set the table mapping of file extensions to mime types in the system state

Default table is defined in Text.XML.HXT.DOM.MimeTypeDefaults. This table is used when reading loacl files, (file: protocol) to determine the mime type

set the table mapping of file extensions to mime types by an external config file

The config file must follow the conventions of etcmime.types on a debian linux system, that means all empty lines and all lines starting with a # are ignored. The other lines must consist of a mime type followed by a possible empty list of extensions. The list of extenstions and mime types overwrites the default list in the system state of the IOStateArrow

System Configuration and Options

42 declarations

Specify the set of accepted mime types.

All contents of documents for which the mime type is not found in this list are discarded.

Configure compression and decompression for binary serialization/deserialization. First component is the compression function applied after serialization, second the decompression applied before deserialization.

withDefaultBaseURI URI , input option, set the default base URI

This option can be useful when parsing documents from stdin or contained in a string, and interpreting relative URIs within the document

Force a given mime type for all file contents.

The mime type for file access will then not be computed by looking into a mime.types file

withIgnoreNoneXmlContents yes/no : input option, ignore document contents of none XML/HTML documents.

This option can be useful for implementing crawler like applications, e.g. an URL checker. In those cases net traffic can be reduced.

withMimeTypeFile filename : input option, set the mime type table for file: documents by given file. The format of this config file must be in the syntax of a debian linux "mime.types" config file

withOutputEncoding encoding , output option, default is the default input encoding or utf8, if input encoding is not set

withOutputXML : output option, default writing

Default is writing XML: quote special XML chars >,<,",',& where neccessary, add XML processing instruction and encode document with respect to withOutputEncoding

Write XHTML: quote all special XML chars, use HTML entity refs or char refs for none ASCII chars

Write XML: quote only special XML chars, don't substitute chars by HTML entities, and don't generate empty elements for HTML elements, which may contain any contents, e.g. src=.../script instead of src=... /

withParseByMimeType yes/no : read option, select the parser by the mime type of the document (pulled out of the HTTP header).

When the mime type is set to "text/html" the configured HTML parser is taken, when it's set to "text/xml" or "text/xhtml" the configured XML parser is taken. If the mime type is something else, no further processing is performed, the contents is given back to the application in form of a single text node. If the default document encoding is set to isoLatin1, this even enables processing of arbitray binary data.

valuewithProxy :: String -> SysConfig
#

withProxy "host:port" : input option, configure a proxy for HTTP access, e.g. www-cache:3128

valuewithRemoveWS :: Bool -> SysConfig
#

withRemoveWS yes/no : read and write option, remove all whitespace, used for document indentation, default is no

withSubstDTDEntities yes/no: read option, substitute general entities defined in DTD, default is yes. switching this option and the validate option off can lead to faster parsing, because then there is no need to access the DTD

withSubstHTMLEntities yes/no: read option, substitute general entities defined in HTML DTD, default is no. switching this option on and the substDTDEntities and validate options off can lead to faster parsing because there is no need to access a DTD, but still the HTML general entities are substituted

valuewithWarnings :: Bool -> SysConfig
#

withWarnings yes/no : system option, issue warnings during reading, HTML parsing and processing, default is yes