IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Mon March 11, 2002 09:34 AM

    Hello:
    I want to know why there is a HTTP 500 error if there is the last two rows code:
    //------------------------------------
    BasicDocument doc = new BasicDocument();
    BasicElement rootElement = new BasicElement(doc, “rootElement”);

    BasicElement node1 = new BasicElement(doc,“node1”);
    rootElement.appendChild(node1);

    BasicAttribute node1attr = new BasicElement(doc,“node1attr”,“attrvalue”);
    node1.appendChild(node1attr);
    //---------------------------------

    [This message was edited by wangsir on 11 Mar 2002 at 09:12.]


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 2.  RE: How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Mon March 11, 2002 04:29 PM

    Hi,

    could it be that the modifications in the last two lines of code create a document which no longer complies to the schema?

    There will probably be more information in the error log of the Servlet/Container Engine.

    If you could supply some more information on your application (Tamino version, Servlet Engine, etc) we could be of more help!

    Thanks,
    Trevor.


    #API-Management
    #webMethods-Tamino-XML-Server-APIs
    #webMethods


  • 3.  RE: How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Tue March 12, 2002 01:13 AM

    Hi:
    Thanks!
    My development environment:
    Tamino2.3.1.4+Apache1.3.22+Tomcat3.20.
    My intent is adding a data via Jsp,for example:




    I am looking forward to.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 4.  RE: How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Tue March 12, 2002 05:25 PM

    Hello.

    The last two lines look a little strange:
    BasicAttribute node1attr = new BasicElement(doc,“node1attr”,“attrvalue”);

    Is this correct? Should the instantiation be of a “new BasicAttribute” too?

    (This looks likely to cause a problem at some point - instantiating a BasicElement into a BasicAttribute field…)

    Also, I am not sure, but I think that appendChild() may be the wrong way to set an attribute. Isn’t Element.setAttribute(String name, String value) better - or even Element.setAttributeNode(org.w3c.dom.Attr)?

    Perhaps someone more familiar with DOM can comment on this…

    Cheers,
    Trevor.


    #API-Management
    #webMethods
    #webMethods-Tamino-XML-Server-APIs


  • 5.  RE: How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Tue March 12, 2002 06:26 PM

    If you are appending a node as an attribute it should be an instance of an attribute not an element. When the parser checks the nodetype it will get a ELEMENT_NODE type, therefore it will just append an element to your parent node instead of an attribute. Usually, the Element object has a setAttribute method you can use. If you really need to do it by appending, create the instance using the constructor of an attribute node, not an element.


    #webMethods
    #webMethods-Tamino-XML-Server-APIs
    #API-Management


  • 6.  RE: How to use appendChild()?(com.docuverse.dom.BasicAttribute)

    Posted Wed March 13, 2002 07:32 AM

    Sorry,sorry for my carelessness,and Trevor is right.I should have written to “new BasicAttribute”,sorry!
    According to what Jfarjona said,I solved it,thanks!


    #webMethods-Tamino-XML-Server-APIs
    #webMethods
    #API-Management