Right, in my case that Node is a Text. The following is what I'm doing in 
afterRender method; it seems to work just fine although I don't know if that's 
the recommended approach in DOM rewriting.

As usual, thanks a lot for the great assistance, and in particular for pointing 
me to DOM rewriting.

List<Node> nodes = elementToModify.getChildren();

if (nodes.size() == 1)
{
        if (nodes.get(0) instanceof Text)
        {
                Text currentNode = (Text) nodes.get(0);
                
                Text newNode = elementToModify.text("pippo " + 
currentNode.toString());
                
                newNode.moveToTop(elementToModify);
                
                nodes = elementToModify.getChildren();
                
                nodes.get(1).remove();
        }
}

Reply via email to