---- <[EMAIL PROTECTED]> ---- > My question came up because of this portion of the JavaDoc for the > Transformer Factory. ... > This says the Templates object is a compiled representation. > > So you are saying that I am misinterpreting what is in the JavaDoc?
I can't say what your interpretation is; although I can see how the phrasing there is confusing. In the rest of the Xalan documentation there should be a bunch of usage samples as well that should help. JAXP is a set of interfaces - not implementations. The javadoc is the essence of what an implementation should do to support the Templates object, not necessarily a strict description of what it does. The choice of the word 'compiled' representation is probably a bad one: various JAXP implementations can do whatever they want, including compiling straight to machine code, simply pre-parsing the file, or doing just about nothing, as long as the rest of the interface is supported properly. The essence is that the implementation *should* attempt to preprocess the stylesheet as much as possible when creating the Templates object, so that later use of the stylesheet to do transformations is as quick as possible. So the word 'compiled' is probably a bug in the javadoc, if it's causing folks this much confusion. The default xalan implementation (which you're using) implements Templates by parsing the stylesheet and any xsl:import/include statements, and building an in-memory structure of the stylesheet that's pretty much resolved as far as we can go. Calling templates.newTransformer() is fairly lightweight; then when you say transformer.transform(...) all we have to do is start parsing the XML and the transformation starts pretty quickly. The optional xsltc implementation (which is part of the Xalan project) implements Templates by parsing the stylesheet and doing similar prep work to the xalan implementation above, but then also writes a 'translet' Java .class object out thats the actual bytecodes of the transformation. Calling templates.newTransformer() essentially instantiates an object of that translet class, and calling .transform(...) basically just executes that class directly to do the transformation. There are several other JAXP implementations out there as well; they can each do as they see fit as long as the spec is followed. Hope that helps, - Shane
