xmlwf.sgml 13 KB

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