xmlwf.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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>[email protected]</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>-N</option></arg>
  55. <arg><option>-k</option></arg>
  56. <arg><option>-v</option></arg>
  57. <arg>file ...</arg>
  58. </cmdsynopsis>
  59. </refsynopsisdiv>
  60. <refsect1>
  61. <title>DESCRIPTION</title>
  62. <para>
  63. <command>&dhpackage;</command> uses the Expat library to
  64. determine if an XML document is well-formed. It is
  65. non-validating.
  66. </para>
  67. <para>
  68. If you do not specify any files on the command-line, and you
  69. have a recent version of <command>&dhpackage;</command>, the
  70. input file will be read from standard input.
  71. </para>
  72. </refsect1>
  73. <refsect1>
  74. <title>WELL-FORMED DOCUMENTS</title>
  75. <para>
  76. A well-formed document must adhere to the
  77. following rules:
  78. </para>
  79. <itemizedlist>
  80. <listitem><para>
  81. The file begins with an XML declaration. For instance,
  82. <literal>&lt;?xml version="1.0" standalone="yes"?&gt;</literal>.
  83. <emphasis>NOTE:</emphasis>
  84. <command>&dhpackage;</command> does not currently
  85. check for a valid XML declaration.
  86. </para></listitem>
  87. <listitem><para>
  88. Every start tag is either empty (&lt;tag/&gt;)
  89. or has a corresponding end tag.
  90. </para></listitem>
  91. <listitem><para>
  92. There is exactly one root element. This element must contain
  93. all other elements in the document. Only comments, white
  94. space, and processing instructions may come after the close
  95. of the root element.
  96. </para></listitem>
  97. <listitem><para>
  98. All elements nest properly.
  99. </para></listitem>
  100. <listitem><para>
  101. All attribute values are enclosed in quotes (either single
  102. or double).
  103. </para></listitem>
  104. </itemizedlist>
  105. <para>
  106. If the document has a DTD, and it strictly complies with that
  107. DTD, then the document is also considered <emphasis>valid</emphasis>.
  108. <command>&dhpackage;</command> is a non-validating parser --
  109. it does not check the DTD. However, it does support
  110. external entities (see the <option>-x</option> option).
  111. </para>
  112. </refsect1>
  113. <refsect1>
  114. <title>OPTIONS</title>
  115. <para>
  116. When an option includes an argument, you may specify the argument either
  117. separately ("<option>-d</option> output") or concatenated with the
  118. option ("<option>-d</option>output"). <command>&dhpackage;</command>
  119. supports both.
  120. </para>
  121. <variablelist>
  122. <varlistentry>
  123. <term><option>-c</option></term>
  124. <listitem>
  125. <para>
  126. If the input file is well-formed and <command>&dhpackage;</command>
  127. doesn't encounter any errors, the input file is simply copied to
  128. the output directory unchanged.
  129. This implies no namespaces (turns off <option>-n</option>) and
  130. requires <option>-d</option> to specify an output directory.
  131. </para>
  132. </listitem>
  133. </varlistentry>
  134. <varlistentry>
  135. <term><option>-d output-dir</option></term>
  136. <listitem>
  137. <para>
  138. Specifies a directory to contain transformed
  139. representations of the input files.
  140. By default, <option>-d</option> outputs a canonical representation
  141. (described below).
  142. You can select different output formats using <option>-c</option>,
  143. <option>-m</option> and <option>-N</option>.
  144. </para>
  145. <para>
  146. The output filenames will
  147. be exactly the same as the input filenames or "STDIN" if the input is
  148. coming from standard input. Therefore, you must be careful that the
  149. output file does not go into the same directory as the input
  150. file. Otherwise, <command>&dhpackage;</command> will delete the
  151. input file before it generates the output file (just like running
  152. <literal>cat &lt; file &gt; file</literal> in most shells).
  153. </para>
  154. <para>
  155. Two structurally equivalent XML documents have a byte-for-byte
  156. identical canonical XML representation.
  157. Note that ignorable white space is considered significant and
  158. is treated equivalently to data.
  159. More on canonical XML can be found at
  160. http://www.jclark.com/xml/canonxml.html .
  161. </para>
  162. </listitem>
  163. </varlistentry>
  164. <varlistentry>
  165. <term><option>-e encoding</option></term>
  166. <listitem>
  167. <para>
  168. Specifies the character encoding for the document, overriding
  169. any document encoding declaration. <command>&dhpackage;</command>
  170. supports four built-in encodings:
  171. <literal>US-ASCII</literal>,
  172. <literal>UTF-8</literal>,
  173. <literal>UTF-16</literal>, and
  174. <literal>ISO-8859-1</literal>.
  175. Also see the <option>-w</option> option.
  176. </para>
  177. </listitem>
  178. </varlistentry>
  179. <varlistentry>
  180. <term><option>-m</option></term>
  181. <listitem>
  182. <para>
  183. Outputs some strange sort of XML file that completely
  184. describes the input file, including character positions.
  185. Requires <option>-d</option> to specify an output file.
  186. </para>
  187. </listitem>
  188. </varlistentry>
  189. <varlistentry>
  190. <term><option>-n</option></term>
  191. <listitem>
  192. <para>
  193. Turns on namespace processing. (describe namespaces)
  194. <option>-c</option> disables namespaces.
  195. </para>
  196. </listitem>
  197. </varlistentry>
  198. <varlistentry>
  199. <term><option>-N</option></term>
  200. <listitem>
  201. <para>
  202. Adds a doctype and notation declarations to canonical XML output.
  203. This matches the example output used by the formal XML test cases.
  204. Requires <option>-d</option> to specify an output file.
  205. </para>
  206. </listitem>
  207. </varlistentry>
  208. <varlistentry>
  209. <term><option>-p</option></term>
  210. <listitem>
  211. <para>
  212. Tells xmlwf to process external DTDs and parameter
  213. entities.
  214. </para>
  215. <para>
  216. Normally <command>&dhpackage;</command> never parses parameter
  217. entities. <option>-p</option> tells it to always parse them.
  218. <option>-p</option> implies <option>-x</option>.
  219. </para>
  220. </listitem>
  221. </varlistentry>
  222. <varlistentry>
  223. <term><option>-r</option></term>
  224. <listitem>
  225. <para>
  226. Normally <command>&dhpackage;</command> memory-maps the XML file
  227. before parsing; this can result in faster parsing on many
  228. platforms.
  229. <option>-r</option> turns off memory-mapping and uses normal file
  230. IO calls instead.
  231. Of course, memory-mapping is automatically turned off
  232. when reading from standard input.
  233. </para>
  234. <para>
  235. Use of memory-mapping can cause some platforms to report
  236. substantially higher memory usage for
  237. <command>&dhpackage;</command>, but this appears to be a matter of
  238. the operating system reporting memory in a strange way; there is
  239. not a leak in <command>&dhpackage;</command>.
  240. </para>
  241. </listitem>
  242. </varlistentry>
  243. <varlistentry>
  244. <term><option>-s</option></term>
  245. <listitem>
  246. <para>
  247. Prints an error if the document is not standalone.
  248. A document is standalone if it has no external subset and no
  249. references to parameter entities.
  250. </para>
  251. </listitem>
  252. </varlistentry>
  253. <varlistentry>
  254. <term><option>-t</option></term>
  255. <listitem>
  256. <para>
  257. Turns on timings. This tells Expat to parse the entire file,
  258. but not perform any processing.
  259. This gives a fairly accurate idea of the raw speed of Expat itself
  260. without client overhead.
  261. <option>-t</option> turns off most of the output options
  262. (<option>-d</option>, <option>-m</option>, <option>-c</option>, ...).
  263. </para>
  264. </listitem>
  265. </varlistentry>
  266. <varlistentry>
  267. <term><option>-k</option></term>
  268. <listitem>
  269. <para>
  270. When processing multiple files, Expat by default halts after the
  271. the first file with an error. This tells Expat to report the error
  272. but to keep processing.
  273. This can be useful, for example, when testing a filter that converts
  274. many files to XML and you want to quickly find out which conversions
  275. failed.
  276. </para>
  277. </listitem>
  278. </varlistentry>
  279. <varlistentry>
  280. <term><option>-v</option></term>
  281. <listitem>
  282. <para>
  283. Prints the version of the Expat library being used, including some
  284. information on the compile-time configuration of the library, and
  285. then exits.
  286. </para>
  287. </listitem>
  288. </varlistentry>
  289. <varlistentry>
  290. <term><option>-w</option></term>
  291. <listitem>
  292. <para>
  293. Enables support for Windows code pages.
  294. Normally, <command>&dhpackage;</command> will throw an error if it
  295. runs across an encoding that it is not equipped to handle itself. With
  296. <option>-w</option>, &dhpackage; will try to use a Windows code
  297. page. See also <option>-e</option>.
  298. </para>
  299. </listitem>
  300. </varlistentry>
  301. <varlistentry>
  302. <term><option>-x</option></term>
  303. <listitem>
  304. <para>
  305. Turns on parsing external entities.
  306. </para>
  307. <para>
  308. Non-validating parsers are not required to resolve external
  309. entities, or even expand entities at all.
  310. Expat always expands internal entities (?),
  311. but external entity parsing must be enabled explicitly.
  312. </para>
  313. <para>
  314. External entities are simply entities that obtain their
  315. data from outside the XML file currently being parsed.
  316. </para>
  317. <para>
  318. This is an example of an internal entity:
  319. <literallayout>
  320. &lt;!ENTITY vers '1.0.2'&gt;
  321. </literallayout>
  322. </para>
  323. <para>
  324. And here are some examples of external entities:
  325. <literallayout>
  326. &lt;!ENTITY header SYSTEM "header-&amp;vers;.xml"&gt; (parsed)
  327. &lt;!ENTITY logo SYSTEM "logo.png" PNG&gt; (unparsed)
  328. </literallayout>
  329. </para>
  330. </listitem>
  331. </varlistentry>
  332. <varlistentry>
  333. <term><option>--</option></term>
  334. <listitem>
  335. <para>
  336. (Two hyphens.)
  337. Terminates the list of options. This is only needed if a filename
  338. starts with a hyphen. For example:
  339. </para>
  340. <literallayout>
  341. &dhpackage; -- -myfile.xml
  342. </literallayout>
  343. <para>
  344. will run <command>&dhpackage;</command> on the file
  345. <filename>-myfile.xml</filename>.
  346. </para>
  347. </listitem>
  348. </varlistentry>
  349. </variablelist>
  350. <para>
  351. Older versions of <command>&dhpackage;</command> do not support
  352. reading from standard input.
  353. </para>
  354. </refsect1>
  355. <refsect1>
  356. <title>OUTPUT</title>
  357. <para>
  358. <command>&dhpackage;</command> outputs nothing for files which are problem-free.
  359. If any input file is not well-formed, or if the output for any
  360. input file cannot be opened, <command>&dhpackage;</command> prints a single
  361. line describing the problem to standard output.
  362. </para>
  363. <para>
  364. If the <option>-k</option> option is not provided, <command>&dhpackage;</command>
  365. halts upon encountering a well-formedness or output-file error.
  366. If <option>-k</option> is provided, <command>&dhpackage;</command> continues
  367. processing the remaining input files, describing problems found with any of them.
  368. </para>
  369. </refsect1>
  370. <refsect1>
  371. <title>EXIT STATUS</title>
  372. <para>For option <option>-v</option> or <option>-h</option>, <command>&dhpackage;</command> always exits with status code 0. For other cases, the following exit status codes are returned:
  373. <variablelist>
  374. <varlistentry>
  375. <term><option>0</option></term>
  376. <listitem><para>The input files are well-formed and the output (if requested) was written successfully.</para>
  377. </listitem>
  378. </varlistentry>
  379. <varlistentry>
  380. <term><option>1</option></term>
  381. <listitem><para>An internal error occurred.</para>
  382. </listitem>
  383. </varlistentry>
  384. <varlistentry>
  385. <term><option>2</option></term>
  386. <listitem><para>One or more input files were not well-formed or could not be parsed.</para>
  387. </listitem>
  388. </varlistentry>
  389. <varlistentry>
  390. <term><option>3</option></term>
  391. <listitem><para>If using the <option>-d</option> option, an error occurred opening an output file.</para>
  392. </listitem>
  393. </varlistentry>
  394. <varlistentry>
  395. <term><option>4</option></term>
  396. <listitem><para>There was a command-line argument error in how <command>&dhpackage;</command> was invoked.</para>
  397. </listitem>
  398. </varlistentry>
  399. </variablelist>
  400. </para>
  401. </refsect1>
  402. <refsect1>
  403. <title>BUGS</title>
  404. <para>
  405. The errors should go to standard error, not standard output.
  406. </para>
  407. <para>
  408. There should be a way to get <option>-d</option> to send its
  409. output to standard output rather than forcing the user to send
  410. it to a file.
  411. </para>
  412. <para>
  413. I have no idea why anyone would want to use the
  414. <option>-d</option>, <option>-c</option>, and
  415. <option>-m</option> options. If someone could explain it to
  416. me, I'd like to add this information to this manpage.
  417. </para>
  418. </refsect1>
  419. <refsect1>
  420. <title>ALTERNATIVES</title>
  421. <para>
  422. Here are some XML validators on the web:
  423. <literallayout>
  424. http://www.hcrc.ed.ac.uk/~richard/xml-check.html
  425. http://www.stg.brown.edu/service/xmlvalid/
  426. http://www.scripting.com/frontier5/xml/code/xmlValidator.html
  427. http://www.xml.com/pub/a/tools/ruwf/check.html
  428. </literallayout>
  429. </para>
  430. </refsect1>
  431. <refsect1>
  432. <title>SEE ALSO</title>
  433. <para>
  434. <literallayout>
  435. The Expat home page: http://www.libexpat.org/
  436. The W3 XML specification: http://www.w3.org/TR/REC-xml
  437. </literallayout>
  438. </para>
  439. </refsect1>
  440. <refsect1>
  441. <title>AUTHOR</title>
  442. <para>
  443. This manual page was written by &dhusername; &dhemail; for
  444. the &debian; system (but may be used by others). Permission is
  445. granted to copy, distribute and/or modify this document under
  446. the terms of the <acronym>GNU</acronym> Free Documentation
  447. License, Version 1.1.
  448. </para>
  449. </refsect1>
  450. </refentry>