hxt-7.4: doc/hdoc/Text-XML-HXT-Arrow-WriteDocument.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Text.XML.HXT.Arrow.WriteDocument</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>Haskell Xml Toolbox 7.4: The complete API</TD
><TD CLASS="topbut"
><A HREF="http://darcs.fh-wedel.de/hxt/src/./Text/XML/HXT/Arrow/WriteDocument.hs"
>Source code</A
></TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Text.XML.HXT.Arrow.WriteDocument</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>portable</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>experimental</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>Uwe Schmidt (uwe@fh-wedel.de)</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><P
>Version : $Id: WriteDocument.hs,v 1.8 2006<EM
>11</EM
>09 20:27:42 hxml Exp $
</P
><P
>Compound arrow for writing XML documents
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="#v%3AwriteDocument"
>writeDocument</A
> :: <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AAttributes"
>Attributes</A
> -> String -> <A HREF="Text-XML-HXT-Arrow-XmlIOStateArrow.html#t%3AIOStateArrow"
>IOStateArrow</A
> s <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
> <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AwriteDocumentToString"
>writeDocumentToString</A
> :: <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AAttributes"
>Attributes</A
> -> <A HREF="Text-XML-HXT-Arrow-XmlIOStateArrow.html#t%3AIOStateArrow"
>IOStateArrow</A
> s <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
> String</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Documentation</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3AwriteDocument"
></A
><B
>writeDocument</B
> :: <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AAttributes"
>Attributes</A
> -> String -> <A HREF="Text-XML-HXT-Arrow-XmlIOStateArrow.html#t%3AIOStateArrow"
>IOStateArrow</A
> s <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
> <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
></TD
></TR
><TR
><TD CLASS="doc"
><P
>the main filter for writing documents
</P
><P
>this filter can be configured by an option list like <TT
><A HREF="Text-XML-HXT-Arrow-ReadDocument.html#v%3AreadDocument"
>readDocument</A
></TT
>
</P
><P
>usage: <TT
> writeDocument optionList destination </TT
>
</P
><P
>if <TT
> destination </TT
> is the empty string or "-", stdout is used as output device
</P
><P
>available options are
</P
><UL
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_indent"
>a_indent</A
></TT
> : indent document for readability, (default: no indentation)
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_remove_whitespace"
>a_remove_whitespace</A
></TT
> : remove all redundant whitespace for shorten text (default: no removal)
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_output_encoding"
>a_output_encoding</A
></TT
> : encoding of document, default is <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_encoding"
>a_encoding</A
></TT
> or <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Autf8"
>utf8</A
></TT
>
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_output_xml"
>a_output_xml</A
></TT
> : (default) issue XML: quote special XML chars >,<,",',& where neccessary
add XML processing instruction
and encode document with respect to <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_output_encoding"
>a_output_encoding</A
></TT
>,
if explicitly switched of, the plain text is issued, this is useful
for non XML output, e.g. generated Haskell code, LaTex, Java, ...
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_output_html"
>a_output_html</A
></TT
> : issue XHTML: quote alle XML chars, use HTML entity refs or char refs for none ASCII chars
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_no_xml_pi"
>a_no_xml_pi</A
></TT
> : suppress generation of <?xml ... ?> processing instruction
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_show_tree"
>a_show_tree</A
></TT
> : show tree representation of document (for debugging)
</LI
><LI
> <TT
><A HREF="Text-XML-HXT-DOM-XmlKeywords.html#v%3Aa_show_haskell"
>a_show_haskell</A
></TT
> : show Haskell representaion of document (for debugging)
</LI
></UL
><P
>a minimal main program for copying a document
has the following structure:
</P
><PRE
> module Main
where
import Text.XML.HXT.Arrow
main :: IO ()
main
= do
runX ( readDocument [] "hello.xml"
>>>
writeDocument [] "bye.xml"
)
return ()
</PRE
><P
>an example for copying a document to standard output with tracing and evaluation of
error code is:
</P
><PRE
> module Main
where
import Text.XML.HXT.Arrow
import System.Exit
main :: IO ()
main
= do
[rc] <- runX ( readDocument [ (a_trace, "1")
] "hello.xml"
>>>
writeDocument [ (a_output_encoding, isoLatin1)
] "-" -- output to stdout
>>>
getErrStatus
)
exitWith ( if rc >= c_err
then ExitFailure 1
else ExitSuccess
)
</PRE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3AwriteDocumentToString"
></A
><B
>writeDocumentToString</B
> :: <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AAttributes"
>Attributes</A
> -> <A HREF="Text-XML-HXT-Arrow-XmlIOStateArrow.html#t%3AIOStateArrow"
>IOStateArrow</A
> s <A HREF="Text-XML-HXT-DOM-TypeDefs.html#t%3AXmlTree"
>XmlTree</A
> String</TD
></TR
><TR
><TD CLASS="doc"
>Convert a document into a string. Formating is done the same way
and with the same options as in <TT
><A HREF="Text-XML-HXT-Arrow-WriteDocument.html#v%3AwriteDocument"
>writeDocument</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 0.8</TD
></TR
></TABLE
></BODY
></HTML
>