Women in Technology

Hear us Roar



Article:
  Parsing an XML Document with XPath
Subject:   Parsing a Namespace node with JDK 5.0
Date:   2005-01-14 08:38:33
From:   dvohra09
Response to: Parsing a Namespace node with JDK 5.0

Include the interface methods in the implementation class.


An implementation of NamespaceContext with a single prefix corresponding to a namespace uri.


public class NamespaceContextImpl implements NamespaceContext{


public String uri;
public String prefix;


public NamespaceContextImpl(){}


public NamespaceContextImpl(String prefix, String uri){
this.uri=uri;
this.prefix=prefix;
}


public String getNamespaceURI(String prefix){
return uri;
}
public void setNamespaceURI(String uri){
this.uri=uri;
}


public String getPrefix(String uri){
return prefix;
}


public void setPrefix(String prefix){
this.prefix=prefix;
}
public Iterator getPrefixes(String uri){return null;}


}


Main Topics Oldest First

Showing messages 1 through 1 of 1.

  • Parsing a Namespace node with JDK 5.0
    2005-01-14 08:56:42  Deepak Vohra | [View]

    XPath xpath;
    NamespaceContext namepsaceContext=new NamespaceContextImpl(prefix, uri);
    xpath.setNamespaceContext(namespaceContext);




    public class NamespaceContextImpl implements NamespaceContext{
    public String uri;
    public String prefix;
    public NamespaceContextImpl(){}
    public NamespaceContextImpl(String prefix, String uri){
    this.uri=uri;
    this.prefix=prefix;
    }
    public String getNamespaceURI(String prefix){
    return uri;
    }
    public void setNamespaceURI(String uri){
    this.uri=uri;
    }
    public String getPrefix(String uri){
    return prefix;
    }
    public void setPrefix(String prefix){
    this.prefix=prefix;
    }
    public Iterator getPrefixes(String uri){return null;}
    }