Robby Pelssers wrote:
> 
> i am trying to use the validating transformer with a DTD but can't get it to 
> work.

IIRC when i set this up for Apache Forrest a while back,
then i could not get DTD validation working either.
So we converted the DTD to RELAX NG using Trang.

Some of the notes and links here might help:
http://forrest.apache.org/howto-dev.html#debug-validation
https://issues.apache.org/jira/browse/FOR-1172

(I have been trying to investigate this for ages.
Sorry, not much time, so i hope this much helps.)

No matter what i do to configure the transformer, there are only
three default grammar for SchemaParser instantiated
(DEBUG messages in core.log). Two for "RELAX NG" and one for
XML Schema, and none for DTD.

Been twiddling sitemap.xmap (and forrest.xmap) and cocoon.xconf files.

Trying to specify a grammar for the particular use in the
sitemap match, then requesting the validation report gives
"Unsupported grammar language".

Not specifying a grammar, then requesting the validation report gives
"The markup in the document preceding the root element must be well-formed"

The logs show that the DTD has been resolved by the
catalog entity resolver.

There is a message for "Detecting grammar" for the DTD,
but no resolution message for "detected for schema" like
there is for RNG validation.

Then we get the error message for "markup" as above,
a SAXParseException.
This line of the DTD is the first "<!ENTITY ..." declaration.
So it is not parsing it as a DTD.

Note that Forrest still uses Cocoon-2.1 but IIRC then this Validation
block is the same.

Need to look at the Cocoon Samples. Perhaps there is a reason
that Pier did provide a DTD sample in the beginning.

Another thought: I wonder if this is because our "xml-parser"
is configured in cocoon.xconf to have validate=false.

-David

> I already took a look at the source and found this block of code in 
> http://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-validation/cocoon-validation-impl/src/main/java/org/apache/cocoon/components/validation/jaxp/JaxpSchemaParser.java
> 
> I tried 
> 
>              <map:transform src="data/p-topic.dtd" type="validate">
>                <map:parameter name="grammar" 
> value="http://www.w3.org/TR/REC-xml"/>
>              </map:transform>  
> which does not work.
> 
> -------------------------------------------------------------------------
>         /* Detect languages or use the supplied ones */
>         Configuration languages[] = 
> conf.getChild("grammars").getChildren("grammar");
>         Set grammars = new HashSet();
>         if (languages.length > 0) {
> 
>             /* If the configuration specified (formally) a list of grammars 
> use it */
>             for (int x = 0; x < languages.length; x++) {
>                 String language = languages[x].getValue();
>                 if (fact.isSchemaLanguageSupported(language)) {
>                     grammars.add(language);
>                     continue;
>                 }
>                 /* If the configured language is not supported throw an 
> exception */
>                 String message = "JAXP SchemaFactory \"" + this.className + 
> "\" " +
>                                  "does not support configured grammar " + 
> language;
>                 throw new ConfigurationException(message, languages[x]);
>             }
>         } else {
> 
>             /* Attempt to detect the languages directly using the JAXP 
> factory */
>             if (fact.isSchemaLanguageSupported(Validator.GRAMMAR_XML_SCHEMA)) 
> {
>                 grammars.add(Validator.GRAMMAR_XML_SCHEMA);
>             }
>             if (fact.isSchemaLanguageSupported(Validator.GRAMMAR_RELAX_NG)) {
>                 grammars.add(Validator.GRAMMAR_RELAX_NG);
>             }
>             if (fact.isSchemaLanguageSupported(Validator.GRAMMAR_XML_DTD)) {
>                 grammars.add(Validator.GRAMMAR_XML_DTD);  //this equals 
> "http://www.w3.org/TR/REC-xml";
>             }
>         }
> 
> 
> Is there a way to configure support for DTD validation as well?  XML schema 
> validation seems to work out-of-the-box.
> 
> Kind regards,
> Robby

Reply via email to