webMethods

webMethods

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 insert a DOM to Tamino XML DB

    Posted Thu February 19, 2004 02:35 PM

    Hi all,


    If I have a XML Doc as following:


    Bill
    Killer


    How to change it into DOM and insert this XML Object to Tamino XML DB?

    Is it enough to do that by Tamino API for JAVA?
    I know the following code can insert XML Object to DB:

    TXMLObject newPatient = TXMLObject.newInstance(patient123);
    response = accessor.insert(newPatient);

    However, how to change the XML Doc into DOM(e.g. patient123)?


    Snake


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


  • 2.  RE: How to insert a DOM to Tamino XML DB

    Posted Thu February 19, 2004 04:02 PM

    If you’re asking how to get raw xml into a DOM, that really depends on the Object Model you are using and the original form of your xml (String, File etc). If you’re using DOM (as opposed to JDOM) you can try:

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();  
    Document myDoc = builder.parse(source); </pre><BR>Your source can be a java.io.File, an InputSource, an InputStream or a URI.<BR>If your xml is a String you can use:<BR><pre class="ip-ubbcode-code-pre">Document myDoc = builder.parse(new ByteArrayInputStream(source.getBytes()));  



    HTH.


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


  • 3.  RE: How to insert a DOM to Tamino XML DB

    Posted Thu February 19, 2004 04:39 PM

    An alternative is to create a TXMLObject directly from a java.lang.String:

      
    String patientrawxml = "<patient><name .... ";
    ...
    TXMLObject patient = TXMLObject.newInstance(patientrawxml);
    </pre><BR><BR>Then you can insert this. <BR><BR>If you want to manipulate the TXMLObject as a DOM object before inserting it you can use the getDocument() method of TXMLObject, e.g<BR><pre class="ip-ubbcode-code-pre">
    TXMLObject patient = TXMLObject.newInstance(patientrawxml);
    Document patientdom = (Document)patient.getDocument();
    // do stuff using DOM ...


    remembering to cast the Object returned from getDocument() to a Document object.

    There is a small advantage to Bills’ suggestion in that you can utilise Xerces specific parser features if this is a requirement.

    For more information on Xerces, DOM and JAXP please have a look at http://xml.apache.org/xerces2-j/API.html.

    HTH,

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


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


  • 4.  RE: How to insert a DOM to Tamino XML DB

    Posted Thu February 19, 2004 05:17 PM

    Thx 2 Special Advisors,
    In Stuart reply, which stated that “// do stuff using DOM …”, did you imply that the document “patientdom” didn’t recognize the document structure I inputted so that I need to do somethings, e.g. define back the root, childs, etc., or you just mean to edit/manipulate the XML document content?


    Snake


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


  • 5.  RE: How to insert a DOM to Tamino XML DB

    Posted Fri February 20, 2004 09:47 AM

    I just mean to edit/manipulate, e.g. if you want to change anything prior to inserting it.

    HTH

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


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


  • 6.  RE: How to insert a DOM to Tamino XML DB

    Posted Fri February 20, 2004 12:53 PM


  • 7.  RE: How to insert a DOM to Tamino XML DB

    Posted Mon February 23, 2004 06:21 PM

    Hi 2 Advisor,

    Do you know any methods can parse Schema to build a DOM Tree?? I mean how can I establish the XML structure by the given Schema dynamically.

    Thx


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


  • 8.  RE: How to insert a DOM to Tamino XML DB

    Posted Tue February 24, 2004 03:43 PM

    Would JaxMe or JaxMe2 be useful? They implement the JAXB specification to bind your xml schema/dtd to java classes.
    HTH


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