You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by da...@cocoon.zones.apache.org on 2005/09/14 00:08:42 UTC

[DAISY] Created: ValidationReportTransformer

A new document has been created.

http://cocoon.zones.apache.org/daisy/documentation/691.html

Document ID: 691
Branch: main
Language: default
Name: ValidationReportTransformer
Document Type: Document
Created: 9/13/05 10:08:22 PM
Creator (owner): Pier Fumagalli
State: publish

Parts
=====

Content
-------
Mime type: text/xml
Size: 3436 bytes
Content:
<html>
<body>

<p>The <tt>ValidatingTransformer</tt> provides a very simple
<tt>Transformer</tt> implementation validating documents in a pipeline using the
validation framework provided by the validation block.</p>

<p>The configuration for this transformer is extremely easy: Like any other
component, it needs to be declared in a sitemap's
<tt>&lt;map:components/&gt;</tt> section:</p>

<pre>&lt;map:components&gt;
  ...
  &lt;map:transformers default="..."&gt;
    ...
<strong>    &lt;map:transformer name="validate"
      logger="sitemap.transformer.validate"
      src="org.apache.cocoon.transformation.ValidatingTransformer"&gt;
   
      &lt;!--+ The "grammar" an optional configuration element specifying the default
            | grammar used by the validator. When the "grammar" element is specified,
            | the automatic detection of schema types will be disabled.
            |
            | This can also be specifed in pipelines as a parameter:
            |   &lt;map:parameter name="grammar" value="... grammar identifier ..."/&gt;
            |
            | For a list of well known grammars, see the JavaDoc documentation for the
            | org.apache.cocoon.components.validation.Validator interface.
            +--&gt;
      &lt;!-- &lt;grammar&gt;... grammar identifier ...&lt;/grammar&gt; --&gt;
    &lt;/map:transformer&gt;
</strong>
    ...
  &lt;/map:transformers&gt;
&lt;/map:components&gt;
</pre>

<p>The only defined (but <strong>not required</strong>) configuration element
for this component is <tt>&lt;grammar&gt;<em>... grammar identifier
...</em>&lt;/grammar&gt;</tt> indicating the grammar to pass to the Validator
component. See the documentation of the validation block for more information on
what this means.</p>

<p>The use of the <tt>ValidatingTransformer</tt> is again extremely simple.
Simply declare it in the pipeline like any other transformer:</p>

<pre>&lt;map:pipeline type="..."&gt;
  ...

  &lt;map:match src="..."&gt;
    &lt;map:generate src="..."/&gt;
    ...
    <strong>&lt;map:transform type="jing" src="myschema.rng"&gt;
      &lt;!-- &lt;map:parameter name="grammar" value="... identifier ..."/&gt; --&gt;
    &lt;/map:transform&gt;
   </strong> ...
    &lt;map:serialize type="..."/&gt;
  &lt;/map:match&gt;

  ...
&lt;/map:pipeline&gt;
</pre>

<p>Following the example above, the document being processed in the pipeline
will be validated using the "<tt>myschema.rng</tt>" schema (the
<tt>Validator</tt> will autodetect this to be a
<a href="http://relax-ng.org/">RELAX-NG</a> schema), and the entire pipeline
will fail throwing a <tt>SAXException</tt> if an error was detected validating.
</p>

<p>The optional "<tt>grammar</tt>" parameter will override at run time whatever
configuration parameter was specified in the <tt>&lt;map:components/&gt;</tt>
section of the pipeline. For example one might not declare a grammar in the
configuration (letting the normal grammar auto-detection to work) and override
it for a specific pipeline with the XML DTD grammar identifier (which can't be
detected, as it's not an XML document).</p>

<p>Note that if multiple errors occur in any document, only the first one will
be reported: this transformer doesn't give you a report of all errors in the
document, it simply fail on the first error detected. Another transformer, the
<tt>ValidationReportTransformer</tt> allows to produce validation reports.</p>

</body>
</html>

Collections
===========
The document belongs to the following collections: documentation