You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

xmlvalidate.html 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <html>
  2. <head>
  3. <title>XMLValidate Task</title>
  4. </head>
  5. <body>
  6. <h2><a name="xmlvalidate">XMLValidate</a></h2>
  7. <h3>Description</h3>
  8. <p>This task checks xml files are valid (or only well formed). The
  9. task uses the SAX2 parser implementation provided by JAXP by default
  10. (probably the one that is used by Ant itself), but one can specify any
  11. SAX1/2 parser if needed.</p>
  12. <p>This task supports the use of nested <a
  13. href="../CoreTypes/xmlcatalog.html">xmlcatalog</a> elements and/or nested
  14. <tt>&lt;dtd&gt;</tt> elements which are used to resolve DTDs and entities.</p>
  15. <h3>Parameters</h3>
  16. <table border="1" cellpadding="2" cellspacing="0">
  17. <tr>
  18. <td valign="top"><b>Attribute</b></td>
  19. <td valign="top"><b>Description</b></td>
  20. <td align="center" valign="top"><b>Required</b></td>
  21. </tr>
  22. <tr>
  23. <td valign="top">file</td>
  24. <td valign="top">the file(s) you want to check. (optionally can use an embedded fileset)</td>
  25. <td valign="top" align="center">No</td>
  26. </tr>
  27. <tr>
  28. <td valign="top">lenient</td>
  29. <td valign="top">
  30. if true, only check the xml document is well formed
  31. (ignored if the specified parser is as SAX1 parser)
  32. </td>
  33. <td valign="top" align="center">No</td>
  34. </tr>
  35. <tr>
  36. <td valign="top">classname</td>
  37. <td valign="top">the parser to use.</td>
  38. <td align="center" valign="top">No</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">classpathref</td>
  42. <td valign="top">where to find the parser class. Optionally can use an embedded classpath element.</td>
  43. <td align="center" valign="top">No</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">failonerror</td>
  47. <td valign="top">fails on a error if set to true (defaults to true).</td>
  48. <td align="center" valign="top">No</td>
  49. </tr>
  50. <tr>
  51. <td valign="top">warn</td>
  52. <td valign="top">log parser warn events.</td>
  53. <td align="center" valign="top">No</td>
  54. </tr>
  55. </table>
  56. <h3><a name="nested">Nested Elements</a></h3>
  57. <h4>dtd</h4>
  58. &lt;dtd&gt; is used to specify different locations for DTD resolution.
  59. <table border="1" cellpadding="2" cellspacing="0">
  60. <tr>
  61. <td width="12%" valign="top"><b>Attribute</b></td>
  62. <td width="78%" valign="top"><b>Description</b></td>
  63. <td width="10%" valign="top"><b>Required</b></td>
  64. </tr>
  65. <tr>
  66. <td valign="top">publicId</td>
  67. <td valign="top">Public ID of the DTD to resolve</td>
  68. <td align="center" valign="top">Yes</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">location</td>
  72. <td valign="top">Location of the DTD to use, which can be a file,
  73. a resource, or a URL</td>
  74. <td align="center" valign="top">Yes</td>
  75. </tr>
  76. </table>
  77. <h4>xmlcatalog</h4>
  78. <p>The <a href="../CoreTypes/xmlcatalog.html">xmlcatalog</a>
  79. element is used to perform Entity resolution.</p>
  80. <h3>Examples</h3>
  81. <pre>
  82. &lt;xmlvalidate file="toto.xml"/&gt;
  83. </pre>
  84. Validate toto.xml
  85. <pre>
  86. &lt;xmlvalidate failonerror="no" lenient="yes" warn="yes"
  87. classname="org.apache.xerces.parsers.SAXParser"&gt;
  88. classpath="lib/xerces.jar"&gt;
  89. &lt;fileset dir="src" includes="style/*.xsl"/&gt;
  90. &lt;/xmlvalidate&gt;
  91. </pre>
  92. Validate all .xsl files in src/style, but only warn if there is an error, rather than
  93. halt the build.
  94. <pre>
  95. &lt;xmlvalidate file="struts-config.xml" warn="false"&gt;
  96. &lt;dtd publicId="-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
  97. location="struts-config_1_0.dtd"/&gt;
  98. &lt;/xmlvalidate&gt;
  99. </pre>
  100. Validate a struts configuration, using a local copy of the DTD.
  101. <pre>
  102. &lt;xmlvalidate failonerror="no"&gt;
  103. &lt;fileset dir="${project.dir}" includes="**/*.xml"/&gt;
  104. &lt;xmlcatalog refid="mycatalog"/&gt;
  105. &lt;/xmlvalidate&gt;
  106. </pre>
  107. Scan all XML files in the project, using a predefined catalog to map URIs to local files.
  108. <pre>
  109. &lt;xmlvalidate failonerror="no"&gt;
  110. &lt;fileset dir="${project.dir}" includes="**/*.xml"/&gt;
  111. &lt;xmlcatalog&gt;
  112. &lt;dtd
  113. publicId=&quot;-//ArielPartners//DTD XML Article V1.0//EN&quot;
  114. location=&quot;com/arielpartners/knowledgebase/dtd/article.dtd&quot;/&gt;
  115. &lt;/xmlcatalog&gt;
  116. &lt;/xmlvalidate&gt;
  117. </pre>
  118. Scan all XML files in the project, using the catalog defined inline.
  119. <hr>
  120. <p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All rights
  121. Reserved.</p>
  122. </body>
  123. </html>