You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Warren, David" <dw...@rsasecurity.com> on 2003/04/15 05:03:41 UTC

empty xmlns attribute

Hi,

I've been scratching my head trying to figure out why the following code
fragment generates 8 attributes even though only 7 are set.  The extra
attribute is 'xmlns=""'.

...
public final static String XML_NS = "http://www.w3.org/XML/1998/namespace";
public final static String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
public final static String SAMLP_NS =
"urn:oasis:names:tc:SAML:1.0:protocol";
public final static String SAML_NS =
"urn:oasis:names:tc:SAML:1.0:assertion";
public final static String XMLSIG_NS = "http://www.w3.org/2000/09/xmldsig#";
...
Element r = doc.createElementNS(XML.SAMLP_NS, "samlp:Request");
r.setAttributeNS(XMLNS_NS, "xmlns:samlp", XML.SAMLP_NS);
r.setAttributeNS(XMLNS_NS, "xmlns:saml", XML.SAML_NS);
r.setAttributeNS(XMLNS_NS, "xmlns:ds", XML.XMLSIG_NS);
r.setAttributeNS(null, "MajorVersion", "1");
r.setAttributeNS(null, "MinorVersion", "0");
r.setAttributeNS(null, "RequestID", requestId);
SimpleDateFormat formatter = new
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
r.setAttributeNS(null, "IssueInstant", formatter.format(issueInstant));
...

I've been using xerces 2.0.1 but I tried the latest jars (2.4.0) and I
get the same behavior.

Can someone help?

TIA,
David
--
Obligatory .signatory
David Warren       phone: 781-515-7152
RSA Security Inc., 174 Middlesex Turnpike, Bedford, MA 01730
dwarren@rsasecurity.com



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: empty xmlns attribute

Posted by Joseph Kesselman <ke...@us.ibm.com>.
You've specified several attributes with no prefix and no namespace. If 
there was a default namespace inhereted at this point, the serializer must 
generate xmlns="" to clear that default. See the Namespaces In XML spec.


______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. 
"may'ron DaroQbe'chugh vaj bIrIQbej"  ("Put down the squeezebox and nobody 
gets hurt.")