xmlwf.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <!DOCTYPE refentry [
  2. <!-- Fill in your name for FIRSTNAME and SURNAME. -->
  3. <!ENTITY dhfirstname "<firstname>Scott</firstname>">
  4. <!ENTITY dhsurname "<surname>Bronson</surname>">
  5. <!-- Please adjust the date whenever revising the manpage. -->
  6. <!ENTITY dhdate "<date>March 11, 2016</date>">
  7. <!-- SECTION should be 1-8, maybe w/ subsection other parameters are
  8. allowed: see man(7), man(1). -->
  9. <!ENTITY dhsection "<manvolnum>1</manvolnum>">
  10. <!ENTITY dhemail "<email>bronson@rinspin.com</email>">
  11. <!ENTITY dhusername "Scott Bronson">
  12. <!ENTITY dhucpackage "<refentrytitle>XMLWF</refentrytitle>">
  13. <!ENTITY dhpackage "xmlwf">
  14. <!ENTITY debian "<productname>Debian GNU/Linux</productname>">
  15. <!ENTITY gnu "<acronym>GNU</acronym>">
  16. ]>
  17. <refentry>
  18. <refentryinfo>
  19. <address>
  20. &dhemail;
  21. </address>
  22. <author>
  23. &dhfirstname;
  24. &dhsurname;
  25. </author>
  26. <copyright>
  27. <year>2001</year>
  28. <holder>&dhusername;</holder>
  29. </copyright>
  30. &dhdate;
  31. </refentryinfo>
  32. <refmeta>
  33. &dhucpackage;
  34. &dhsection;
  35. </refmeta>
  36. <refnamediv>
  37. <refname>&dhpackage;</refname>
  38. <refpurpose>Determines if an XML document is well-formed</refpurpose>
  39. </refnamediv>
  40. <refsynopsisdiv>
  41. <cmdsynopsis>
  42. <command>&dhpackage;</command>
  43. <arg><option>-s</option></arg>
  44. <arg><option>-n</option></arg>
  45. <arg><option>-p</option></arg>
  46. <arg><option>-x</option></arg>
  47. <arg><option>-e <replaceable>encoding</replaceable></option></arg>
  48. <arg><option>-w</option></arg>
  49. <arg><option>-d <replaceable>output-dir</replaceable></option></arg>
  50. <arg><option>-c</option></arg>
  51. <arg><option>-m</option></arg>
  52. <arg><option>-r</option></arg>
  53. <arg><option>-t</option></arg>
  54. <arg><option>-v</option></arg>
  55. <arg>file ...</arg>
  56. </cmdsynopsis>
  57. </refsynopsisdiv>
  58. <refsect1>
  59. <title>DESCRIPTION</title>
  60. <para>
  61. <command>&dhpackage;</command> uses the Expat library to
  62. determine if an XML document is well-formed. It is
  63. non-validating.
  64. </para>
  65. <para>
  66. If you do not specify any files on the command-line, and you
  67. have a recent version of <command>&dhpackage;</command>, the
  68. input file will be read from standard input.
  69. </para>
  70. </refsect1>
  71. <refsect1>
  72. <title>WELL-FORMED DOCUMENTS</title>
  73. <para>
  74. A well-formed document must adhere to the
  75. following rules:
  76. </para>
  77. <itemizedlist>
  78. <listitem><para>
  79. The file begins with an XML declaration. For instance,
  80. <literal>&lt;?xml version="1.0" standalone="yes"?&gt;</literal>.
  81. <emphasis>NOTE:</emphasis>
  82. <command>&dhpackage;</command> does not currently
  83. check for a valid XML declaration.
  84. </para></listitem>
  85. <listitem><para>
  86. Every start tag is either empty (&lt;tag/&gt;)
  87. or has a corresponding end tag.
  88. </para></listitem>
  89. <listitem><para>
  90. There is exactly one root element. This element must contain
  91. all other elements in the document. Only comments, white
  92. space, and processing instructions may come after the close
  93. of the root element.
  94. </para></listitem>
  95. <listitem><para>
  96. All elements nest properly.
  97. </para></listitem>
  98. <listitem><para>
  99. All attribute values are enclosed in quotes (either single
  100. or double).
  101. </para></listitem>
  102. </itemizedlist>
  103. <para>
  104. If the document has a DTD, and it strictly complies with that
  105. DTD, then the document is also considered <emphasis>valid</emphasis>.
  106. <command>&dhpackage;</command> is a non-validating parser --
  107. it does not check the DTD. However, it does support
  108. external entities (see the <option>-x</option> option).
  109. </para>
  110. </refsect1>
  111. <refsect1>
  112. <title>OPTIONS</title>
  113. <para>
  114. When an option includes an argument, you may specify the argument either
  115. separately ("<option>-d</option> output") or concatenated with the
  116. option ("<option>-d</option>output"). <command>&dhpackage;</command>
  117. supports both.
  118. </para>
  119. <variablelist>
  120. <varlistentry>
  121. <term><option>-c</option></term>
  122. <listitem>
  123. <para>
  124. If the input file is well-formed and <command>&dhpackage;</command>
  125. doesn't encounter any errors, the input file is simply copied to
  126. the output directory unchanged.
  127. This implies no namespaces (turns off <option>-n</option>) and
  128. requires <option>-d</option> to specify an output file.
  129. </para>
  130. </listitem>
  131. </varlistentry>
  132. <varlistentry>
  133. <term><option>-d output-dir</option></term>
  134. <listitem>
  135. <para>
  136. Specifies a directory to contain transformed
  137. representations of the input files.
  138. By default, <option>-d</option> outputs a canonical representation
  139. (described below).
  140. You can select different output formats using <option>-c</option>
  141. and <option>-m</option>.
  142. </para>
  143. <para>
  144. The output filenames will
  145. be exactly the same as the input filenames or "STDIN" if the input is
  146. coming from standard input. Therefore, you must be careful that the
  147. output file does not go into the same directory as the input
  148. file. Otherwise, <command>&dhpackage;</command> will delete the
  149. input file before it generates the output file (just like running
  150. <literal>cat &lt; file &gt; file</literal> in most shells).
  151. </para>
  152. <para>
  153. Two structurally equivalent XML documents have a byte-for-byte
  154. identical canonical XML representation.
  155. Note that ignorable white space is considered significant and
  156. is treated equivalently to data.
  157. More on canonical XML can be found at
  158. http://www.jclark.com/xml/canonxml.html .
  159. </para>
  160. </listitem>
  161. </varlistentry>
  162. <varlistentry>
  163. <term><option>-e encoding</option></term>
  164. <listitem>
  165. <para>
  166. Specifies the character encoding for the document, overriding
  167. any document encoding declaration. <command>&dhpackage;</command>
  168. supports four built-in encodings:
  169. <literal>US-ASCII</literal>,
  170. <literal>UTF-8</literal>,
  171. <literal>UTF-16</literal>, and
  172. <literal>ISO-8859-1</literal>.
  173. Also see the <option>-w</option> option.
  174. </para>
  175. </listitem>
  176. </varlistentry>
  177. <varlistentry>
  178. <term><option>-m</option></term>
  179. <listitem>
  180. <para>
  181. Outputs some strange sort of XML file that completely
  182. describes the input file, including character positions.
  183. Requires <option>-d</option> to specify an output file.
  184. </para>
  185. </listitem>
  186. </varlistentry>
  187. <varlistentry>
  188. <term><option>-n</option></term>
  189. <listitem>
  190. <para>
  191. Turns on namespace processing. (describe namespaces)
  192. <option>-c</option> disables namespaces.
  193. </para>
  194. </listitem>
  195. </varlistentry>
  196. <varlistentry>
  197. <term><option>-p</option></term>
  198. <listitem>
  199. <para>
  200. Tells xmlwf to process external DTDs and parameter
  201. entities.
  202. </para>
  203. <para>
  204. Normally <command>&dhpackage;</command> never parses parameter
  205. entities. <option>-p</option> tells it to always parse them.
  206. <option>-p</option> implies <option>-x</option>.
  207. </para>
  208. </listitem>
  209. </varlistentry>
  210. <varlistentry>
  211. <term><option>-r</option></term>
  212. <listitem>
  213. <para>
  214. Normally <command>&dhpackage;</command> memory-maps the XML file
  215. before parsing; this can result in faster parsing on many
  216. platforms.
  217. <option>-r</option> turns off memory-mapping and uses normal file
  218. IO calls instead.
  219. Of course, memory-mapping is automatically turned off
  220. when reading from standard input.
  221. </para>
  222. <para>
  223. Use of memory-mapping can cause some platforms to report
  224. substantially higher memory usage for
  225. <command>&dhpackage;</command>, but this appears to be a matter of
  226. the operating system reporting memory in a strange way; there is
  227. not a leak in <command>&dhpackage;</command>.
  228. </para>
  229. </listitem>
  230. </varlistentry>
  231. <varlistentry>
  232. <term><option>-s</option></term>
  233. <listitem>
  234. <para>
  235. Prints an error if the document is not standalone.
  236. A document is standalone if it has no external subset and no
  237. references to parameter entities.
  238. </para>
  239. </listitem>
  240. </varlistentry>
  241. <varlistentry>
  242. <term><option>-t</option></term>
  243. <listitem>
  244. <para>
  245. Turns on timings. This tells Expat to parse the entire file,
  246. but not perform any processing.
  247. This gives a fairly accurate idea of the raw speed of Expat itself
  248. without client overhead.
  249. <option>-t</option> turns off most of the output options
  250. (<option>-d</option>, <option>-m</option>, <option>-c</option>, ...).
  251. </para>
  252. </listitem>
  253. </varlistentry>
  254. <varlistentry>
  255. <term><option>-v</option></term>
  256. <listitem>
  257. <para>
  258. Prints the version of the Expat library being used, including some
  259. information on the compile-time configuration of the library, and
  260. then exits.
  261. </para>
  262. </listitem>
  263. </varlistentry>
  264. <varlistentry>
  265. <term><option>-w</option></term>
  266. <listitem>
  267. <para>
  268. Enables support for Windows code pages.
  269. Normally, <command>&dhpackage;</command> will throw an error if it
  270. runs across an encoding that it is not equipped to handle itself. With
  271. <option>-w</option>, &dhpackage; will try to use a Windows code
  272. page. See also <option>-e</option>.
  273. </para>
  274. </listitem>
  275. </varlistentry>
  276. <varlistentry>
  277. <term><option>-x</option></term>
  278. <listitem>
  279. <para>
  280. Turns on parsing external entities.
  281. </para>
  282. <para>
  283. Non-validating parsers are not required to resolve external
  284. entities, or even expand entities at all.
  285. Expat always expands internal entities (?),
  286. but external entity parsing must be enabled explicitly.
  287. </para>
  288. <para>
  289. External entities are simply entities that obtain their
  290. data from outside the XML file currently being parsed.
  291. </para>
  292. <para>
  293. This is an example of an internal entity:
  294. <literallayout>
  295. &lt;!ENTITY vers '1.0.2'&gt;
  296. </literallayout>
  297. </para>
  298. <para>
  299. And here are some examples of external entities:
  300. <literallayout>
  301. &lt;!ENTITY header SYSTEM "header-&amp;vers;.xml"&gt; (parsed)
  302. &lt;!ENTITY logo SYSTEM "logo.png" PNG&gt; (unparsed)
  303. </literallayout>
  304. </para>
  305. </listitem>
  306. </varlistentry>
  307. <varlistentry>
  308. <term><option>--</option></term>
  309. <listitem>
  310. <para>
  311. (Two hyphens.)
  312. Terminates the list of options. This is only needed if a filename
  313. starts with a hyphen. For example:
  314. </para>
  315. <literallayout>
  316. &dhpackage; -- -myfile.xml
  317. </literallayout>
  318. <para>
  319. will run <command>&dhpackage;</command> on the file
  320. <filename>-myfile.xml</filename>.
  321. </para>
  322. </listitem>
  323. </varlistentry>
  324. </variablelist>
  325. <para>
  326. Older versions of <command>&dhpackage;</command> do not support
  327. reading from standard input.
  328. </para>
  329. </refsect1>
  330. <refsect1>
  331. <title>OUTPUT</title>
  332. <para>
  333. If an input file is not well-formed,
  334. <command>&dhpackage;</command> prints a single line describing
  335. the problem to standard output. If a file is well formed,
  336. <command>&dhpackage;</command> outputs nothing.
  337. Note that the result code is <emphasis>not</emphasis> set.
  338. </para>
  339. </refsect1>
  340. <refsect1>
  341. <title>BUGS</title>
  342. <para>
  343. <command>&dhpackage;</command> returns a 0 - noerr result,
  344. even if the file is not well-formed. There is no good way for
  345. a program to use <command>&dhpackage;</command> to quickly
  346. check a file -- it must parse <command>&dhpackage;</command>'s
  347. standard output.
  348. </para>
  349. <para>
  350. The errors should go to standard error, not standard output.
  351. </para>
  352. <para>
  353. There should be a way to get <option>-d</option> to send its
  354. output to standard output rather than forcing the user to send
  355. it to a file.
  356. </para>
  357. <para>
  358. I have no idea why anyone would want to use the
  359. <option>-d</option>, <option>-c</option>, and
  360. <option>-m</option> options. If someone could explain it to
  361. me, I'd like to add this information to this manpage.
  362. </para>
  363. </refsect1>
  364. <refsect1>
  365. <title>ALTERNATIVES</title>
  366. <para>
  367. Here are some XML validators on the web:
  368. <literallayout>
  369. http://www.hcrc.ed.ac.uk/~richard/xml-check.html
  370. http://www.stg.brown.edu/service/xmlvalid/
  371. http://www.scripting.com/frontier5/xml/code/xmlValidator.html
  372. http://www.xml.com/pub/a/tools/ruwf/check.html
  373. </literallayout>
  374. </para>
  375. </refsect1>
  376. <refsect1>
  377. <title>SEE ALSO</title>
  378. <para>
  379. <literallayout>
  380. The Expat home page: http://www.libexpat.org/
  381. The W3 XML specification: http://www.w3.org/TR/REC-xml
  382. </literallayout>
  383. </para>
  384. </refsect1>
  385. <refsect1>
  386. <title>AUTHOR</title>
  387. <para>
  388. This manual page was written by &dhusername; &dhemail; for
  389. the &debian; system (but may be used by others). Permission is
  390. granted to copy, distribute and/or modify this document under
  391. the terms of the <acronym>GNU</acronym> Free Documentation
  392. License, Version 1.1.
  393. </para>
  394. </refsect1>
  395. </refentry>