[jdom-interest] setAttributes method

Ed Maher ed.maher at euromainbt.co.uk
Tue Oct 12 02:04:15 PDT 2004


Hi,

Given that getAttributes returns a 'live' list, is should not be necessary to call setAttributes at all.
Indeed, calling setAttributes is causing your attribute list to be cleared.
Please take a look at the JavaDoc for these methods for a definitive explanation.

To achieve what you want, I think you can just remove the setAttributes call, and all should be ok.

Hope that helps.
Ed.

  ----- Original Message ----- 
  From: Mauricio García 
  To: jdom-interest at jdom.org 
  Sent: Tuesday, October 12, 2004 1:56 AM
  Subject: [jdom-interest] setAttributes method


  Hi ,

  I've tried to use a List object to set the order of the attributes of my 
  element.  For example I have the next code:

  List list = elem.getAttributes();
  Attribute attrib = new 
  Attribute("schemaLocation",getSchemaLocation(),getSchemaInstance());
  list.add(0,attrib);
  System.out.println(list);
  elem.setAttributes(list);
  System.out.println(elem);

  But, when get the output of my element I can see it has no attributes, but 
  the list had 2 attributes.  Console shows me:

  [Attribute: xsi:schemaLocation="http://www.mmm.cl/SiiDte EnvioDTE_v10.xsd"], 
  [Attribute: version="1.0"]
  [Element: <EnvioDTE [Namespace: http://www.mmm.cl/SiiDte]/>]

  What can I do?  Does not the Element's method "setAttributes" work?

  Note: when I use: 
  elem.setAttribute("schemaLocation",getSchemaLocation(),getSchemaInstance()); 
  it works!  But I need this attribute be the first.

  _________________________________________________________________
  Express yourself instantly with MSN Messenger! Download today it's FREE! 
  http://messenger.msn.com/

  _______________________________________________
  To control your jdom-interest membership:
  http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://servlets.com/pipermail/jdom-interest/attachments/20041012/b7613d69/attachment.htm


More information about the jdom-interest mailing list