cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Updated: ValidationReportTransformer
Date Sat, 18 Mar 2006 19:20:43 GMT
A document has been updated:

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

Document ID: 691
Branch: main
Language: default
Name: ValidationReportTransformer (unchanged)
Document Type: Sitemap Component (previously: Cocoon Document)
Updated on: 3/18/06 7:15:18 PM
Updated by: Bruno Dumon

A new version has been created, state: publish

Parts
=====
Content
-------
This part has been removed.

Long description
----------------
This part has been added.
Mime type: text/xml
File name: null
Size: 3924 bytes
Content:
<html>
<body>

<p>The <tt>ValidationReportTransformer</tt> is a <tt>Transformer</tt>
preparing
reports about the validation of a document in Cocoon pipeline using the
validation framework provided by the <a href="daisy:683">validation block</a>.
</p>

<p>To configure this transformer do as with 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="validation-report"
      logger="sitemap.transformer.validate"
      src="org.apache.cocoon.transformation.ValidationReportTransformer"&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 <a href="daisy:683">validation block</a>
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="validation-report" 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>After the validation is completed, the <tt>ValidationReportTransformer</tt>
will emit a report somehow similar to this one:</p>

<pre>&lt;report xmlns="http://apache.org/cocoon/validation/1.0"&gt;
  &lt;warning system="..." public="..." line="..." column="..."&gt;
    ... detailed message ...
  &lt;/warning&gt;
  &lt;error system="..." public="..." line="..." column="..."&gt;
    ... detailed message ...
  &lt;/error&gt;
  &lt;fatal system="..." public="..." line="..." column="..."&gt;
    ... message ...
  &lt;/fatal&gt;
&lt;/report&gt;
</pre>

<p>The location attributes specified in the <tt>&lt;warning/&gt;</tt>,
<tt>&lt;error/&gt;</tt> and <tt>&lt;fatal/&gt;</tt>
tags are all optional and
will be generated only if known.</p>

</body>
</html>


Fields
======
no changes

Links
=====
no changes

Custom Fields
=============
no changes

Collections
===========
no changes

Mime
View raw message