You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by do...@cocoon.apache.org on 2004/08/10 14:50:12 UTC

[Cocoon Wiki] Updated: ValidationTransformer

   Date: 2004-08-10T05:50:11
   Editor: DavidPérez <dp...@fcc.es>
   Wiki: Cocoon Wiki
   Page: ValidationTransformer
   URL: http://wiki.apache.org/cocoon/ValidationTransformer

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,8 +1,10 @@
-=== Description ===
+=== ValidatorTransformer ===
+
+==== Description ====
 
 In this page I present a [:Transformer] that can be inserted in any stage of an XML pipeline, in order to validate its contents.  This can be a powerful tool for debugging and conformance testing.  All detected errors and warnings are dumped to the logs.  The transformer uses directly SAX events in order to validate.
 
-=== Declaration ===
+==== Declaration ====
 
 In order to use it first you have to declare the transformer as a sitemap component:
 
@@ -14,7 +16,7 @@
 </map:transformers>
 }}}
 
-=== Use ===
+==== Use ====
 
 Here is an excerpt of a pipeline that uses this transformer, to check that we are generating valid HTML.
 
@@ -31,7 +33,7 @@
 
 As you can see in the {{{src}}} attribute we pass a URL that points to a DTD, Relax NG Schema or XML Schema.  Any valid protocol is valid, even the {{{cocoon:}}} one.
 
-=== Configuration ===
+==== Configuration ====
 
 Normally, we will want to deactivate the checking in production sites, in order to gain speed, so I have created a parameter called {{{active}}} that allows easily deactivating it.
 
@@ -51,6 +53,65 @@
  *  stop-for-errors, default value {{{false}}}.
  *  stop-for-warnings, default value {{{false}}}.
  *  stop-for-fatal, default value {{{true}}}.
+
+=== ValidationReportTransformer ===
+
+==== Description ====
+
+It is very similar to the previous one.
+It generates a report about the conformance of the XML data it receives with any schema, DTD supplied to the transformer.
+Can be useful for debugging or quality control purposes
+
+It generates an output XML document whose root element is called {{report}} and may have child elements {{fatal-error}}, {{error}}, {{warning}}.  This report can easily be transformed to a HTML report through a simple XSTL sheet.
+
+{{{
+<report>
+       <error>Detected error 1</error>
+       <warning>Detected warning 1</warning>
+       <error>Detected error 2</error>
+       <fatal-error>Detected fatal error 1</fatal-error>
+       <warning>Detected warning 2</warning>
+</report>
+}}}
+
+In case the input XML document is valid an empty report will be generated.
+{{{
+<report>
+</report>
+}}}
+
+==== Declaration ====
+
+In order to use it first you have to declare the transformer as a sitemap component:
+
+{{{
+<map:transformers>
+	....
+	<map:transformer logger='transf.validate' name='validate' src='fcc.ima.cocoon.ValidatorTransformer'/>
+	....
+</map:transformers>
+}}}
+
+==== Use ====
+
+Here is an excerpt of a pipeline that uses this transformer, to check that we are generating valid HTML.
+
+{{{
+<map:resource name='html'>
+	<map:generate src='my-file.xml'/>
+	<map:transform type='my-transform'/>
+	<map:transform type='validate' src='validation/xhtml1-transitional.dtd'>
+		<map:parameter name='active' value='true'/>
+	</map:transform>
+	<map:serialize type='html'/>
+</map:resource>
+}}}
+
+As you can see in the {{{src}}} attribute we pass a URL that points to a DTD, Relax NG Schema or XML Schema.  Any valid protocol is valid, even the {{{cocoon:}}} one.
+
+==== Configuration ====
+
+Nothing is needed
 
 === Pre-requisites ===