Tracing xsl:include and xsl:import
Added by Anonymous over 15 years ago
Legacy ID: #7424439 Legacy Poster: Marian Schedenig (musgit)
Hi! I have to create a log of certain elements and all stylesheets that have been processed during a transformation task. I have control over my stylesheets, so I can use xsl:message and a custom message emitter to trigger events for relevant elements. However, as xsl:message is not allowed as a top-level element, I cannot use it to trace the inclusion of external stylesheets. I've been trying to use a trace listener, but it seems to get information about all elements except xsl:include and xsl:import. Any hints on how I can get events when exterenal stylesheets are loaded? Thx, Marian.
Replies (2)
RE: Tracing xsl:include and xsl:import - Added by Anonymous over 15 years ago
Legacy ID: #7424540 Legacy Poster: Michael Kay (mhkay)
The TraceListener only reports run-time events, not compile-time events, but xsl:include and xsl:import happen entirely at compile time. You can specify a compile-time URIResolver which is asked to resolve include and import declarations, and you could use this to trace the call (it can simply delegate the actual resolution to the standard URIResolver by returning null from its resolve() method. However, this will not distinguish whether the call is include or import. The other way to do it would be to write a stylesheet that statically examines your source stylesheet and reports on the include and import elements (there's an example of this in my book).
RE: Tracing xsl:include and xsl:import - Added by Anonymous over 15 years ago
Legacy ID: #7424927 Legacy Poster: Marian Schedenig (musgit)
Thanks for the quick reply. I had been thinking about using URIResolver (I don't have to distinguish between import/include) but was hoping there would be a more "direct" solution after the URI has been successfully resolved. But since transformation will fail on invalid URIs anyway, I guess I can deal with log entries for those URIs. The stylesheet approach sounds intriguing, but my requirement is to do the logging for each individual transformation, and I don't really want to separate resource logging and element logging too much. Cheers, Marian.
Please register to reply