Hi Mukul,
I found a way to get the processed result as a string and count it:
function count(context, elem){
transf = context.getTransformer();
count=transf.transformToString(elem).length();
transf.executeChildTemplates(elem,true);
return "";
}
Is it possible to add an attribute to the parent node?
Thanks
Jan
Mukul Gandhi schrieb:
Hi Jan,
Perhaps you can do this in two passes. In the first pass, you copy the tree:
<text>
some words
some more words
</text>
in some variable. Then in second pass, you can find the count of words
and create the required attribute.
On Thu, Jun 18, 2009 at 5:59 PM, Jan Hoeft<m...@janhoeft.de> wrote:
Hi,
is it possible to get the result tree and work on it?
I am able to do the transformation on my own via executeChildTemplates. But
I have not found a way to process the result.
<xalan:component prefix="my" elements="countwords">
<xalan:script lang="javascript">
function countwords(context, elem){
transf = context.getTransformer();
transf.executeChildTemplates(elem,true);
return "";
}
</xalan:script>
</xalan:component>
<xsl:template match="/">
<my:countwords>
<text>
some words
<xsl:value-of select="."/>
</text>
</my:countwords>
</xsl:template>
my xml file:
<root>
some more words
</root>
What i am trying to do is to add an attribute count to the text output.
<text count="5">
some words
some more words
</text>
Any idea how to do this?
Cheers
Jan