You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Henry Zongaro <zo...@ca.ibm.com> on 2006/03/08 15:14:50 UTC

Re: Xalan Parser error

Hello.

"Bondada, Mohana Rao RAO (ELS-OXF)" <M....@elsevier.com> wrote on 
2006-03-08 06:28:26 AM:
> I am getting the following error when I run the parsing against 
> following XSL. 
> Can you please suggest what could be the problem.
> 
> In google I have seen a message saying, this was coming with some 
> versions of Xalan.jar, we are using Xalan Java 2.2.D11.
> http://mail-archives.apache.org/mod_mbox/xml-xalan-j-users/200312.
> mbox/%3C004101c3c95c$1f098e40$1400a8c0@dima%3E
> 
> Error Message:
> [Error] common_templates.xsl:119:79: Element type "xsl:stylesheet" 
> must be declared.

     I believe that, in some circumstances, old versions of Xalan-Java 
enabled the Xerces-J dynamic validation feature on the parser used to 
parse a stylesheet.  If this feature is enabled while parsing an XML 
document (including a stylesheet) that contains a DTD, the parser will 
attempt to validate the input document, but if it doesn't contain a DTD, 
the parser will not attempt to validate the input document.  Your example 
stylesheet contains a DTD, but no declarations for the elements in the 
stylesheet, so validation fails.

     Xalan-J was changed to no longer set the Xerces-J dynamic validation 
feature beginning with version 2.5.0.  To resolve the problem, you could 
move to a more recent version of the Xalan-J, modify your DTD to include 
declarations for all the elements in the stylesheet (probably not easy), 
or remove the DTD (which is also probably not easy, given that your 
stylesheet is using the DTD to declare entities).

     If your application is using the JAXP APIs to perform the 
transformation, another possible work-around is to create an XMLReader and 
use a SAXSource containing that XMLReader and your stylesheet to create a 
Transformer object.  Old versions of Xalan-J did not set the dynamic 
validation feature on an XMLReader created by the user's application.

     I hope that helps.

Thanks,

Henry
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com