I've now managed to run this in the debugger (by writing a JUnit test that invokes Ant via its Java API and running this JUnit test within IntelliJ). This demonstrates that Ant is supplying the source file to Saxon in the form of a SAXSource with a pre-initialized XMLReader, as I suspected. Saxon won't use the configured source parser in preference to one that's supplied in the SAXSource object used as input to the transform() method.

Perhaps I should add a Configuration option that causes it to do so. The trouble about such options is that few users will ever discover them...

Anyway, I've learned how to debug Saxon-running-under-Ant, which is a useful new trick.

Michael Kay
Saxonica


On 09/01/2013 14:50, Jirka Kosek wrote:
On 9.1.2013 10:42, Michael Kay wrote:
I haven't confirmed this, but my suspicion is that Ant is supplying
Saxon with a SAXSource in which the XMLReader is already initialized, in
which case Saxon will use that XMLReader.
I even tried to understand the source code of XSLT task. It's calling
transform() method where source document is supplied as instance of File
class. So it seems that Saxon should be responsible for creating parser
for this file.

Is it possible to investigate this by setting the system property
jaxp.debug=1? This will show whether the parser is being located using
the JAXP search mechanism. If this is the case, it almost certainly
means that Ant rather than Saxon is loading the XML parser.
e:\proj\amu\kosi-help\build>ant
Buildfile: e:\proj\amu\kosi-help\build\build.xml
JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
JAXP: loaded from fallback value:
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
JAXP: created new instance of class
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
ClassLoader: null

xslt:
     [xslt] Processing e:\proj\amu\kosi-help\data\AMU_KOSI_manual 3b.htm
to e:\proj\amu\kosi-help\build\out.xml
     [xslt] Loading stylesheet e:\proj\amu\kosi-help\xsl\test.xsl
     [xslt] JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
     [xslt] JAXP: loaded from fallback value:
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
     [xslt] JAXP: created new instance of class
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
ClassLoader: null

     [xslt] JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
     [xslt] JAXP: loaded from fallback value:
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
     [xslt] JAXP: created new instance of class
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
ClassLoader: null

     [xslt] JAXP: find factoryId =javax.xml.parsers.SAXParserFactory
     [xslt] JAXP: loaded from fallback value:
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl
     [xslt] JAXP: created new instance of class
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl using
ClassLoader: null

     [xslt] e:\proj\amu\kosi-help\data\AMU_KOSI_manual 3b.htm:9:18:
Fatal Error! Error reported by XML parser Cause: org.xml.sax.SAX
ParseException: Open quote is expected for attribute "{1}" associated
with an  element type  "http-equiv".
     [xslt] Failed to process e:\proj\amu\kosi-help\data\AMU_KOSI_manual
3b.htm

BUILD FAILED

Another useful experiment would be to see whether other Saxon
configuration properties work, e.g. set
http://saxon.sf.net/feature/timing to "true".
Yes, this is working.

A workaround would probably be to use the exec task to run Saxon, rather
than the xslt task.
Yes, thanks, that's reasonoble workaround. I just thought that XSLT task
is more "proper" way to invoke XSLT from the Ant. :-)

Thanks,

				Jirka



------------------------------------------------------------------------------
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help