You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Nicholas Remy <nr...@caci.com> on 2004/04/02 17:15:47 UTC

Emply xmlns attribute

Group,

The following code snippet:

<snip>
            SOAPFactory sf = SOAPFactory.newInstance();
            Name bodyName = sf.createName("getImage", "i", 
"http://www.mycompany.com");
            SOAPBodyElement sbe = soapBody.addBodyElement(bodyName);
 

            Name usrName = sf.createName("user");
            SOAPElement usr = sbe.addAttribute(usrName, "keymaster");
            Name pwdName = sf.createName("pwd");
            SOAPElement pwd = sbe.addAttribute(pwdName, "gatekeeper");
 

            Name latName = sf.createName("item");
            SOAPElement lat = sbe.addChildElement(latName);
            lat.addTextNode("12345");
</snip>



...produces the following SOAP:

<snip>

 <i:getImage user="keymaster" pwd="gatekeeper" 
xmlns:i="http://www.mycompany.com">
   <item xmlns="">12345</item>
  </i:getImage>

</snip>



The tutorials and examples I used to build the code gave no indication 
that the xmlns attribute would be present--let alone blank.  Is there a 
way to avoid the empty/null xmlns (xmlns="")?


Thank you!


Nicholas (Nick) Remy




RE: Emply xmlns attribute

Posted by Robert Lowe <rm...@rmlowe.com>.
Nick,

The following fragments:

 <i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
   <item xmlns="">12345</item>
  </i:getImage>

 <i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
   <i:item>12345</item>
  </i:getImage>

are *not* equivalent in general. Which one is correct depends on your
schema. Specifically, the first is correct if the schema specifies
elementFormDefault="unqualified", or if the schema doesn't include the
elementFormDefault attribute; the second is correct if the schema specifies
elementFormDefault="qualified".


Best regards,

Robert Lowe
http://RMLowe.com/



-----Original Message-----
From: Nicholas Remy [mailto:nremy@caci.com]
Sent: Friday, April 02, 2004 11:16 PM
To: axis-user@ws.apache.org
Subject: Emply xmlns attribute



Group,

The following code snippet:

<snip>
            SOAPFactory sf = SOAPFactory.newInstance();
            Name bodyName = sf.createName("getImage", "i",
"http://www.mycompany.com");
            SOAPBodyElement sbe = soapBody.addBodyElement(bodyName);


            Name usrName = sf.createName("user");
            SOAPElement usr = sbe.addAttribute(usrName, "keymaster");
            Name pwdName = sf.createName("pwd");
            SOAPElement pwd = sbe.addAttribute(pwdName, "gatekeeper");


            Name latName = sf.createName("item");
            SOAPElement lat = sbe.addChildElement(latName);
            lat.addTextNode("12345");
</snip>



...produces the following SOAP:

<snip>

 <i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
   <item xmlns="">12345</item>
  </i:getImage>

</snip>



The tutorials and examples I used to build the code gave no indication that
the xmlns attribute would be present--let alone blank.  Is there a way to
avoid the empty/null xmlns (xmlns="")?


Thank you!


Nicholas (Nick) Remy