1xmlwrite(3am)              GNU Awk Extension Modules             xmlwrite(3am)
2
3
4

NAME

6       xmlwrite  -  Provides facilities for writing XML fragments. A whole XML
7       document can be  composed  this  way.  The  composed  document  may  be
8       indented if desired.
9

SYNOPSIS

11       @include "xmlwrite"
12
13       xwopen(filename[, options])
14       xwclose()
15
16       xwdeclaration(version, encoding, standalone)
17       xwstartdoct(root, pubid, sysid)
18       xwenddoct()
19
20       xwprocinst(name, string)
21       xwcomment(comment)
22
23       xwstarttag(name)
24       xwattrib(name, value)
25       xwendtag(name)
26
27       xwtext(string)
28       xwstartcdata()
29       xwendcdata()
30
31       xwunparsed(string)
32
33       xwdoctype(root, pubid, sysid, declarations)
34       xwstyle(type, uri)
35       xwelement(name, content)
36       xwcdata(string)
37       xwcopy()
38

DESCRIPTION

40       The xmlwrite library facilitates writing a XML document serially, piece
41       by piece. It takes care of some peculiarities of the XML standard, like
42       metacharacters escaping, whitespace handling, markup indentation, etc.
43
44   Output file and mode
45       xwopen(filename[, options])
46              Initializes  output  to the given file. The optional argument is
47              an array of named options:
48
49              options["INDENT"]
50                     Indent step (-1 = no indent), default = 2.
51
52              options["QUOTE"]
53                     Preferred quote character (', "), default = (").
54
55       xwclose()
56              Closes the current opened output file.
57
58   XML prologue
59       xwdeclaration(version, encoding, standalone)
60              Writes an XML declaration (<?xml ... ?>). All the arguments  are
61              optional.
62
63       xwstartdoct(root, pubid, sysid)
64              Writes  the  starting  part  of a DOCTYPE declaration (<!DOCTYPE
65              ...). All the arguments are optional.Internal  DOCTYPE  declara‐
66              tions, if any, may be inserted by subsequent xwunparsed() calls.
67
68       xwenddoct()
69              Writes the closing mark of the DOCTYPE declaration (]>).
70
71   Processing Instructions and Comments
72       xwprocinst(name, string)
73              Prints a Processing Instruction with the given name and contents
74              (<?name string?>).
75
76       xwcomment(comment)
77              Prints a XML comment (<!--comment-->).
78
79   Elements and attributes
80       xwstarttag(name)
81              Prints the opening mark of an element start tag (<name ...>).
82
83       xwattrib(name, value)
84              Prints an attribute  markup  fragment  (name="value").  Must  be
85              invoked immediately after the xwstartag() call.
86
87       xwendtag(name)
88              Prints  an  element  closing  tag  (</name>).  If the element is
89              empty, just closes its collapsed markup (/>).
90
91   Character data
92       xwtext(string)
93              Writes the escaped text. If it is invoked inside  a  CDATA  sec‐
94              tion, the text is written unescaped.
95
96       xwstartcdata()
97              Writes the opening mark of a CDATA section (<![CDATA[).
98
99       xwendcdata()
100              Writes the closing mark of a CDATA section (]]>).
101
102   Unparsed markup
103       xwunparsed(string)
104              Writes a text fragment literally. Can be used to directly insert
105              special markup fragments.
106
107   Higher level convenience functions
108       xwdoctype(root, pubid, sysid, declarations)
109              Writes a complete DOCTYPE declaration with a  single  call.  All
110              the arguments are optional.
111
112       xwstyle(type, uri)
113              Writes  a  stylesheet  processing  instruction (<?xsl-stylesheet
114              type="text/type" href="uri"?>).
115
116       xwelement(name, content)
117              Writes a complete simple element  markup  with  a  single  call.
118              Attributes are not supported. Nested child elements are not sup‐
119              ported.
120
121       xwcdata(string)
122              Writes a complete CDATA section with a single call.
123
124   Integration with the XML extension
125       If the xmlwrite library and the gawk-xml extension are  used  together,
126       then it is possible to directly copy XML input markup.
127
128       xwcopy()
129              Writes  the  markup fragment equivalent to the current XML input
130              token. Should be used instead of the XmlCopy() function provided
131              by the xmlcopy library.
132

NOTES

134       xmlwrite  is a standalone library that can be used independently of the
135       gawk-xml extension.
136

BUGS

138       Improper use of  the  provided  functions  may  produce  non-wellformed
139       markup.
140
141       The  whole output document must be written with the provided functions.
142       Mixing xmlwrite calls and direct print commands may  produce  corrupted
143       markup.
144