HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulehxt-9.3.1.22Haskell2010

Text.XML.HXT.Arrow.XmlState

the interface for the basic state maipulation functions

Contents
  1. Data Types
  2. User State Manipulation
  3. Run IO State arrows
  4. Global System State Configuration and Access
  5. Error Handling
  6. Tracing
  7. Document Base
  8. URI Manipulation
  9. Mime Type Handling
  10. System Configuration and Options
Synopsis
  • Packagehxt-9.3.1.22
  • Exports113
  • LanguageHaskell2010
  • LicenceMIT
  • SourceXmlState.hs

Data Types

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

User State Manipulation

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

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

Error Handling

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

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

URI Manipulation

Mime Type Handling

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

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

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

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.

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