santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenneth Jensen <>
Subject ElementProxy troubles
Date Mon, 28 Feb 2005 10:16:54 GMT
Hi guys,

I'm working on some XKMS stuff, and thought I could reuse the
ElementProxy class from package. The
thing is, it doesn't do as I expect it to, so I'm inclined to just
hack up my own version.

The addTextElement( String text, String localname) doesn't append the
new element to the tree, and I don't really see why, so if anyone
could enlighten me please. :)

Below is a code example to illustrate my question, and I use the
xml-security code from CVS (from some day in last week). The output I
expect is something like this:

<myrootelement xmlns="mynamespace">
  <mytextelement xmlns="">

-but the actual output is:


I've been staring at it for some time, so I hope I'm not missing
something obvious.


import org.w3c.dom.*;
import org.apache.xerces.dom.*;

public class MyElementProxyTester {

	public static void main(String[] args) throws Exception {;

        // get DOM implementation and create a new document object
	    DOMImplementation builder = DOMImplementationImpl.getDOMImplementation();
	    Document doc = builder.createDocument( "mynamespace",
"myrootelement", null  );
        // make an ElementProxy for the document
        ElementProxy ep = new MyElementProxy( doc );
        // add a text element to the element through the ElementProxy
        ep.addTextElement("sometext", "mytextelement" );
        // check if it works
        XMLUtils.outputDOM( ep.getDocument().getDocumentElement(), System.out );
class MyElementProxy extends ElementProxy {
    public MyElementProxy( Document doc ){
        super( doc);
    public String getBaseLocalName(){
        return "mylocalname";
    public String getBaseNamespace(){
        return "mynamespace";

View raw message