I am using Xalan and Java for extending a stylesheet.
(Similar example to what I am doing the开发者_开发百科re : Dictionary example)
I struggle to make my tag do an <xsl:apply-templates/>
. I wish to have this :
<xsl:template match="sometag">
<my-java:tag>
<xsl:apply-tempates/>
</my-java:tag>
</xsl:template>
My java class containing the method tag(XSLProcessorContext context, ElemExtensionCall elem)
builds an element myElem
fed into the context like this :
context.outputToResultTree(context.getStylesheet(), myElem);
But I wish to apply the templates defined in the stylesheet to subelements of myElem
.
How can I fire the <xsl:apply-templates/>
from within my Java class ? Is it possible ?
In Xalan I'm doing
TransformerImpl transf = context.getTransformer();
for ( int i = fromValue; i <= toValue; i++ ) {
setInt(variable, i);
transf.executeChildTemplates(elem, true );
}
The idea is to execute a for loop ( the from and to values ) repeating the code inside that x times. Not sure about the 'true' on the executeChildTemplates though - seems to work.
精彩评论