xmlwf.1 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. '\" -*- coding: us-ascii -*-
  2. .if \n(.g .ds T< \\FC
  3. .if \n(.g .ds T> \\F[\n[.fam]]
  4. .de URL
  5. \\$2 \(la\\$1\(ra\\$3
  6. ..
  7. .if \n(.g .mso www.tmac
  8. .TH XMLWF 1 "March 11, 2016" "" ""
  9. .SH NAME
  10. xmlwf \- Determines if an XML document is well-formed
  11. .SH SYNOPSIS
  12. 'nh
  13. .fi
  14. .ad l
  15. \fBxmlwf\fR \kx
  16. .if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
  17. 'in \n(.iu+\nxu
  18. [\fB-s\fR] [\fB-n\fR] [\fB-p\fR] [\fB-x\fR] [\fB-e \fIencoding\fB\fR] [\fB-w\fR] [\fB-d \fIoutput-dir\fB\fR] [\fB-c\fR] [\fB-m\fR] [\fB-r\fR] [\fB-t\fR] [\fB-N\fR] [\fB-v\fR] [file ...]
  19. 'in \n(.iu-\nxu
  20. .ad b
  21. 'hy
  22. .SH DESCRIPTION
  23. \fBxmlwf\fR uses the Expat library to
  24. determine if an XML document is well-formed. It is
  25. non-validating.
  26. .PP
  27. If you do not specify any files on the command-line, and you
  28. have a recent version of \fBxmlwf\fR, the
  29. input file will be read from standard input.
  30. .SH "WELL-FORMED DOCUMENTS"
  31. A well-formed document must adhere to the
  32. following rules:
  33. .TP 0.2i
  34. \(bu
  35. The file begins with an XML declaration. For instance,
  36. \*(T<<?xml version="1.0" standalone="yes"?>\*(T>.
  37. \fINOTE:\fR
  38. \fBxmlwf\fR does not currently
  39. check for a valid XML declaration.
  40. .TP 0.2i
  41. \(bu
  42. Every start tag is either empty (<tag/>)
  43. or has a corresponding end tag.
  44. .TP 0.2i
  45. \(bu
  46. There is exactly one root element. This element must contain
  47. all other elements in the document. Only comments, white
  48. space, and processing instructions may come after the close
  49. of the root element.
  50. .TP 0.2i
  51. \(bu
  52. All elements nest properly.
  53. .TP 0.2i
  54. \(bu
  55. All attribute values are enclosed in quotes (either single
  56. or double).
  57. .PP
  58. If the document has a DTD, and it strictly complies with that
  59. DTD, then the document is also considered \fIvalid\fR.
  60. \fBxmlwf\fR is a non-validating parser --
  61. it does not check the DTD. However, it does support
  62. external entities (see the \*(T<\fB\-x\fR\*(T> option).
  63. .SH OPTIONS
  64. When an option includes an argument, you may specify the argument either
  65. separately ("\*(T<\fB\-d\fR\*(T> output") or concatenated with the
  66. option ("\*(T<\fB\-d\fR\*(T>output"). \fBxmlwf\fR
  67. supports both.
  68. .TP
  69. \*(T<\fB\-c\fR\*(T>
  70. If the input file is well-formed and \fBxmlwf\fR
  71. doesn't encounter any errors, the input file is simply copied to
  72. the output directory unchanged.
  73. This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
  74. requires \*(T<\fB\-d\fR\*(T> to specify an output directory.
  75. .TP
  76. \*(T<\fB\-d output\-dir\fR\*(T>
  77. Specifies a directory to contain transformed
  78. representations of the input files.
  79. By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
  80. (described below).
  81. You can select different output formats using \*(T<\fB\-c\fR\*(T>,
  82. \*(T<\fB\-m\fR\*(T> and \*(T<\fB\-N\fR\*(T>.
  83. The output filenames will
  84. be exactly the same as the input filenames or "STDIN" if the input is
  85. coming from standard input. Therefore, you must be careful that the
  86. output file does not go into the same directory as the input
  87. file. Otherwise, \fBxmlwf\fR will delete the
  88. input file before it generates the output file (just like running
  89. \*(T<cat < file > file\*(T> in most shells).
  90. Two structurally equivalent XML documents have a byte-for-byte
  91. identical canonical XML representation.
  92. Note that ignorable white space is considered significant and
  93. is treated equivalently to data.
  94. More on canonical XML can be found at
  95. http://www.jclark.com/xml/canonxml.html .
  96. .TP
  97. \*(T<\fB\-e encoding\fR\*(T>
  98. Specifies the character encoding for the document, overriding
  99. any document encoding declaration. \fBxmlwf\fR
  100. supports four built-in encodings:
  101. \*(T<US\-ASCII\*(T>,
  102. \*(T<UTF\-8\*(T>,
  103. \*(T<UTF\-16\*(T>, and
  104. \*(T<ISO\-8859\-1\*(T>.
  105. Also see the \*(T<\fB\-w\fR\*(T> option.
  106. .TP
  107. \*(T<\fB\-m\fR\*(T>
  108. Outputs some strange sort of XML file that completely
  109. describes the input file, including character positions.
  110. Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
  111. .TP
  112. \*(T<\fB\-n\fR\*(T>
  113. Turns on namespace processing. (describe namespaces)
  114. \*(T<\fB\-c\fR\*(T> disables namespaces.
  115. .TP
  116. \*(T<\fB\-N\fR\*(T>
  117. Adds a doctype and notation declarations to canonical XML output.
  118. This matches the example output used by the formal XML test cases.
  119. Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
  120. .TP
  121. \*(T<\fB\-p\fR\*(T>
  122. Tells xmlwf to process external DTDs and parameter
  123. entities.
  124. Normally \fBxmlwf\fR never parses parameter
  125. entities. \*(T<\fB\-p\fR\*(T> tells it to always parse them.
  126. \*(T<\fB\-p\fR\*(T> implies \*(T<\fB\-x\fR\*(T>.
  127. .TP
  128. \*(T<\fB\-r\fR\*(T>
  129. Normally \fBxmlwf\fR memory-maps the XML file
  130. before parsing; this can result in faster parsing on many
  131. platforms.
  132. \*(T<\fB\-r\fR\*(T> turns off memory-mapping and uses normal file
  133. IO calls instead.
  134. Of course, memory-mapping is automatically turned off
  135. when reading from standard input.
  136. Use of memory-mapping can cause some platforms to report
  137. substantially higher memory usage for
  138. \fBxmlwf\fR, but this appears to be a matter of
  139. the operating system reporting memory in a strange way; there is
  140. not a leak in \fBxmlwf\fR.
  141. .TP
  142. \*(T<\fB\-s\fR\*(T>
  143. Prints an error if the document is not standalone.
  144. A document is standalone if it has no external subset and no
  145. references to parameter entities.
  146. .TP
  147. \*(T<\fB\-t\fR\*(T>
  148. Turns on timings. This tells Expat to parse the entire file,
  149. but not perform any processing.
  150. This gives a fairly accurate idea of the raw speed of Expat itself
  151. without client overhead.
  152. \*(T<\fB\-t\fR\*(T> turns off most of the output options
  153. (\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-m\fR\*(T>, \*(T<\fB\-c\fR\*(T>, ...).
  154. .TP
  155. \*(T<\fB\-v\fR\*(T>
  156. Prints the version of the Expat library being used, including some
  157. information on the compile-time configuration of the library, and
  158. then exits.
  159. .TP
  160. \*(T<\fB\-w\fR\*(T>
  161. Enables support for Windows code pages.
  162. Normally, \fBxmlwf\fR will throw an error if it
  163. runs across an encoding that it is not equipped to handle itself. With
  164. \*(T<\fB\-w\fR\*(T>, xmlwf will try to use a Windows code
  165. page. See also \*(T<\fB\-e\fR\*(T>.
  166. .TP
  167. \*(T<\fB\-x\fR\*(T>
  168. Turns on parsing external entities.
  169. Non-validating parsers are not required to resolve external
  170. entities, or even expand entities at all.
  171. Expat always expands internal entities (?),
  172. but external entity parsing must be enabled explicitly.
  173. External entities are simply entities that obtain their
  174. data from outside the XML file currently being parsed.
  175. This is an example of an internal entity:
  176. .nf
  177. <!ENTITY vers '1.0.2'>
  178. .fi
  179. And here are some examples of external entities:
  180. .nf
  181. <!ENTITY header SYSTEM "header\-&vers;.xml"> (parsed)
  182. <!ENTITY logo SYSTEM "logo.png" PNG> (unparsed)
  183. .fi
  184. .TP
  185. \*(T<\fB\-\-\fR\*(T>
  186. (Two hyphens.)
  187. Terminates the list of options. This is only needed if a filename
  188. starts with a hyphen. For example:
  189. .nf
  190. xmlwf \-\- \-myfile.xml
  191. .fi
  192. will run \fBxmlwf\fR on the file
  193. \*(T<\fI\-myfile.xml\fR\*(T>.
  194. .PP
  195. Older versions of \fBxmlwf\fR do not support
  196. reading from standard input.
  197. .SH OUTPUT
  198. If an input file is not well-formed,
  199. \fBxmlwf\fR prints a single line describing
  200. the problem to standard output. If a file is well formed,
  201. \fBxmlwf\fR outputs nothing.
  202. .SH "EXIT STATUS"
  203. For option \*(T<\fB\-v\fR\*(T> or \*(T<\fB\-h\fR\*(T>, \fBxmlwf\fR always exits with status code 0. For other cases, the following exit status codes are returned:
  204. .TP
  205. \*(T<\fB0\fR\*(T>
  206. The input files are well-formed.
  207. .TP
  208. \*(T<\fB1\fR\*(T>
  209. An internal error occurred.
  210. .TP
  211. \*(T<\fB2\fR\*(T>
  212. An input file was not well-formed or could not be parsed.
  213. .TP
  214. \*(T<\fB3\fR\*(T>
  215. If using the \*(T<\fB\-d\fR\*(T> option, an error occurred opening an output file.
  216. .SH BUGS
  217. The errors should go to standard error, not standard output.
  218. .PP
  219. There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
  220. output to standard output rather than forcing the user to send
  221. it to a file.
  222. .PP
  223. I have no idea why anyone would want to use the
  224. \*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
  225. \*(T<\fB\-m\fR\*(T> options. If someone could explain it to
  226. me, I'd like to add this information to this manpage.
  227. .SH ALTERNATIVES
  228. Here are some XML validators on the web:
  229. .nf
  230. http://www.hcrc.ed.ac.uk/~richard/xml\-check.html
  231. http://www.stg.brown.edu/service/xmlvalid/
  232. http://www.scripting.com/frontier5/xml/code/xmlValidator.html
  233. http://www.xml.com/pub/a/tools/ruwf/check.html
  234. .fi
  235. .SH "SEE ALSO"
  236. .nf
  237. The Expat home page: http://www.libexpat.org/
  238. The W3 XML specification: http://www.w3.org/TR/REC\-xml
  239. .fi
  240. .SH AUTHOR
  241. This manual page was written by Scott Bronson <\*(T<[email protected]\*(T>> for
  242. the Debian GNU/Linux system (but may be used by others). Permission is
  243. granted to copy, distribute and/or modify this document under
  244. the terms of the GNU Free Documentation
  245. License, Version 1.1.