You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Lars Huttar <la...@sil.org> on 2006/12/19 18:32:11 UTC

DTD validation: "Unsupported grammar language"

Hello,
I seconded this question on the Cocoon user list but have not received a 
response, so would like to ask the developers.
In Cocoon 2.1.9, we are trying to use ValidationReportTransformer to 
validate our XML against a DTD. I'm looking at the documentation at 
http://cocoon.zones.apache.org/daisy/documentation/864/validation.html 
and 
http://cocoon.zones.apache.org/daisy/documentation/components/1058/g2/691.html.
The validation sample block has examples for validating against RNG and 
XML Schema, but not against a DTD.
Like José quoted below, I'm trying to figure out how to make it work.
Here's my attempt, a copy-and-modify of a match pattern in 
samples\blocks\validation\sitemap.xmap:
      <map:match pattern="report-dtd-valid">
        <map:generate src="source-ok.xml"/>
        <map:transform type="validation-report" src="schema-ok.dtd">
          <map:parameter name="grammar" 
value="http://www.w3.org/TR/REC-xml" />
        </map:transform>
        <map:transform src="context:/stylesheets/system/xml2html.xslt"/>
        <map:serialize/>
      </map:match>

I added the "grammar" parameter, as instructed by the documentation 
referenced above, to the validation-report transformer.
For grammar identifier, the documentation seemed to indicate I should 
use "http://www.w3.org/TR/REC-xml". (I also tried "dtd" just for kicks.)
But the result is that I get the error
    org.apache.cocoon.components.validation.ValidatorException: 
Unsupported grammar languagehttp://www.w3.org/TR/REC-xml

Does this mean there is no support for validating against DTDs? Or am I 
doing something wrong?

Thanks,
Lars


On 10/20/2006 9:34 AM, José Miguel Vieira wrote:
 > Hello,
 >
 > I'm trying to use the validation report features, using a dtd for the
 > validation.
 >
 > What is the correct grammar value for dtd validation? I'm
 > using http://www.w3.org/TR/REC-xml but it returns an "Unsupported
 > grammar language".
 >
 > Thanks,
 > Miguel Vieira
I have the same need and am running into the same dead end. Does anyone
have an answer?
Do we need to add something to cocoon.xconf?

Thanks,
Lars


Re: DTD validation: "Unsupported grammar language"

Posted by Lars Huttar <la...@sil.org>.
On 12/20/2006 6:09 PM, Joerg Heinicke wrote:
> Hello Lars,
>
> just from having a look at the code:
> 1. It's http://www.w3.org/TR/REC-xml (see Validator interface and its 
> declared constants).
That documentation is where I got the string from. Glad for the 
confirmation that it's right.
> 2. This exception is thrown in 
> AbstractValidator.getValidationHandler() in line 327 in the current 
> code. It is thrown when no SchemaParser can be found.
> 3. Grammars and their parsers seem to be configured via 
> Configurable.configure(). So maybe the javadoc for this method [1] is 
> helpful. Otherwise you might need to have a look into the code of this 
> method or do some debugging.
Thanks...
It's a little disappointing when Cocoon bills itself as a web 
development framework that "makes it possible to use a Lego(tm)-like 
approach in building web solutions, hooking together components into 
pipelines *without any required programming*", "with strong foundations 
in *XML-based* server-side web application frameworks,"[1] that users 
have to go dig through the framework source code in order to find out 
whether DTD validation is even possible out of the box.

I looked at the javadoc you mentioned. It seems to suggest that I do 
what I've already done, namely to specify the grammar using          
<map:parameter name="grammar" value="http://www.w3.org/TR/REC-xml" />. I 
confess I don't really understand the stuff about schema factories and 
parsers.

Two other Cocoon users have requested the same thing on the Cocoon user 
list, with no response. I'm sure it would be appreciated if someone 
could figure this out... even if the answer is "no, it's not currently 
supported".

Right now, we're using the third-party 
fcc.ima.cocoon.ValidatorTransformer with Cocoon 2.1.7. However, it 
always reports validation errors as being in line 1 column 1, which is 
not very helpful in finding the error. Apparently this is because the 
generator provides a Locator interface that supplies meaningless 
location info. I was hoping the built-in validation block in Cocoon 
2.1.8+ would do better.

Thanks,
Lars

[1] http://cocoon.apache.org/
>
> Regards
> Jörg
>
> [1] 
> http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/validation/jaxp/JaxpSchemaParser.html#configure(org.apache.avalon.framework.configuration.Configuration) 
>
>
> On 19.12.2006 18:32, Lars Huttar wrote:
>> Hello,
>> I seconded this question on the Cocoon user list but have not 
>> received a response, so would like to ask the developers.
>> In Cocoon 2.1.9, we are trying to use ValidationReportTransformer to 
>> validate our XML against a DTD. I'm looking at the documentation at 
>> http://cocoon.zones.apache.org/daisy/documentation/864/validation.html 
>> and 
>> http://cocoon.zones.apache.org/daisy/documentation/components/1058/g2/691.html. 
>>
>> The validation sample block has examples for validating against RNG 
>> and XML Schema, but not against a DTD.
>> Like José quoted below, I'm trying to figure out how to make it work.
>> Here's my attempt, a copy-and-modify of a match pattern in 
>> samples\blocks\validation\sitemap.xmap:
>>      <map:match pattern="report-dtd-valid">
>>        <map:generate src="source-ok.xml"/>
>>        <map:transform type="validation-report" src="schema-ok.dtd">
>>          <map:parameter name="grammar" 
>> value="http://www.w3.org/TR/REC-xml" />
>>        </map:transform>
>>        <map:transform src="context:/stylesheets/system/xml2html.xslt"/>
>>        <map:serialize/>
>>      </map:match>
>>
>> I added the "grammar" parameter, as instructed by the documentation 
>> referenced above, to the validation-report transformer.
>> For grammar identifier, the documentation seemed to indicate I should 
>> use "http://www.w3.org/TR/REC-xml". (I also tried "dtd" just for kicks.)
>> But the result is that I get the error
>>    org.apache.cocoon.components.validation.ValidatorException: 
>> Unsupported grammar languagehttp://www.w3.org/TR/REC-xml
>>
>> Does this mean there is no support for validating against DTDs? Or am 
>> I doing something wrong?
>>
>> Thanks,
>> Lars
>


Re: DTD validation: "Unsupported grammar language"

Posted by Joerg Heinicke <jo...@gmx.de>.
Hello Lars,

just from having a look at the code:
1. It's http://www.w3.org/TR/REC-xml (see Validator interface and its 
declared constants).
2. This exception is thrown in AbstractValidator.getValidationHandler() 
in line 327 in the current code. It is thrown when no SchemaParser can 
be found.
3. Grammars and their parsers seem to be configured via 
Configurable.configure(). So maybe the javadoc for this method [1] is 
helpful. Otherwise you might need to have a look into the code of this 
method or do some debugging.

Regards
Jörg

[1] 
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/validation/jaxp/JaxpSchemaParser.html#configure(org.apache.avalon.framework.configuration.Configuration)

On 19.12.2006 18:32, Lars Huttar wrote:
> Hello,
> I seconded this question on the Cocoon user list but have not received a 
> response, so would like to ask the developers.
> In Cocoon 2.1.9, we are trying to use ValidationReportTransformer to 
> validate our XML against a DTD. I'm looking at the documentation at 
> http://cocoon.zones.apache.org/daisy/documentation/864/validation.html 
> and 
> http://cocoon.zones.apache.org/daisy/documentation/components/1058/g2/691.html. 
> 
> The validation sample block has examples for validating against RNG and 
> XML Schema, but not against a DTD.
> Like José quoted below, I'm trying to figure out how to make it work.
> Here's my attempt, a copy-and-modify of a match pattern in 
> samples\blocks\validation\sitemap.xmap:
>      <map:match pattern="report-dtd-valid">
>        <map:generate src="source-ok.xml"/>
>        <map:transform type="validation-report" src="schema-ok.dtd">
>          <map:parameter name="grammar" 
> value="http://www.w3.org/TR/REC-xml" />
>        </map:transform>
>        <map:transform src="context:/stylesheets/system/xml2html.xslt"/>
>        <map:serialize/>
>      </map:match>
> 
> I added the "grammar" parameter, as instructed by the documentation 
> referenced above, to the validation-report transformer.
> For grammar identifier, the documentation seemed to indicate I should 
> use "http://www.w3.org/TR/REC-xml". (I also tried "dtd" just for kicks.)
> But the result is that I get the error
>    org.apache.cocoon.components.validation.ValidatorException: 
> Unsupported grammar languagehttp://www.w3.org/TR/REC-xml
> 
> Does this mean there is no support for validating against DTDs? Or am I 
> doing something wrong?
> 
> Thanks,
> Lars