#23 Can't add extensions containing namespaces

RTK Java 0.7.1
open
nobody
5
2005-04-20
2005-04-20
Ben
No

I'm trying to use the EPP version 1.0 to connect to
Neulevel's US registry server. Their extension for
specifying the Nexus category and App Purpose is an
XML string that looks like this and contains namespace.

<?xml version="1.0" encoding="UTF-8"
standalone="no"?><neulevel:extension
xmlns="urn:ietf:params:xml:ns:neulevel-1.0"
xmlns:neulevel="urn:ietf:params:xml:ns:neulevel-1.0"
xsi:schemaLocation="urn:ietf:params:xml:ns:neulevel-
1.0 neulevel-
1.0.xsd"><neulevel:unspec>AppPurpose=P1
NexusCategory=C31/CA</neulevel:unspec></neulevel:e
xtension>

The method "prepareExtensionElement" of the
EPPXMLBase class, has no problems parsing this
XML, but runs into a problem when it tries to import it
into the ContactCreate request.

[java]
com.tucows.oxrs.epprtk.rtk.xml.EPPContactCreate.prep
areExtensionElement() {Wed Apr 20 21:18:27 GMT
2005}[1] : [org.w3c.dom.DOMException] [DOM003
Namespace error]
[java] org.w3c.dom.DOMException: DOM003
Namespace error
[java] at org.apache.xerces.dom.AttrNSImpl.<init>
(AttrNSImpl.java:127)
[java] at
org.apache.xerces.dom.DocumentImpl.createAttributeN
S(DocumentImpl.java:1187)
[java] at
org.apache.xerces.dom.DocumentImpl.importNode
(DocumentImpl.java:861)
[java] at
org.apache.xerces.dom.DocumentImpl.importNode
(DocumentImpl.java:828)
[java] at
org.apache.xerces.dom.DocumentImpl.importNode
(DocumentImpl.java:770)

I absolutely need to use the namespace in the request
above, but the EPPRTK will not take it.

Any suggestions, fixes, workarounds ?

Discussion

  • Jigar Parikh
    Jigar Parikh
    2006-03-21

    Logged In: YES
    user_id=1245153

    Extenstion element is created by calling toXML() by
    EPPXMLBase on your Extension Implementation class.

    Since it creates new Document completely it does not have
    any namespace so you probably should add namespace to your
    extension element.
    You could have method like setCommonAttributes(Element
    element) which takes the extension element and sets the
    attribute like below or whatever you need.

    element.setAttribute("xmlns", "urn:ietf:params:xml:ns:epp-
    1.0");
    element.setAttribute"xmlns:xsi", "http://www.w3.org/2001/XML
    Schema-instance");
    element.setAttribute"xsi:schemaLocation", "urn:ietf:params:x
    ml:ns:epp-1.0 epp-1.0.xsd");

    Once you do this, add other elements to your extension
    element. Now when createXMLFromDoc(document) in your
    extension implementation class gets called, you already
    have namespace so no error will be returned and you will
    get the extension XML string.

    Hope this helps,