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
Expand all | Collapse all

TXMLObject, TXQuery & getDocument()

  • 1.  TXMLObject, TXQuery & getDocument()

    Posted Fri July 30, 2004 01:00 PM

    Hi,
    I am trying to build a java file to access Tamino, perform xquery and use objectModel.dom.TDOMObjectModel for a dom object model.

    Here is my code:

    String queryString = “declare namespace tf = "http://namespaces.softwareag.com/tamino/TaminoFunction\” declare namespace ino = "http://namespaces.softwareag.com/tamino/response2\" for $bib in input()/article return {$bib}"

    // Initiate a xquery
    TXQuery xquery = TXQuery.newInstance( queryString );
    TResponse response = accessor.xquery( xquery );
    TXMLObjectIterator iterator = response.getXMLObjectIterator();
    while ( iterator.hasNext() ) {
    TXMLObject xmlObject = iterator.next();
    // Write the XML content to a StringWriter
    StringWriter stringWriter = new StringWriter();
    xmlObject.writeTo( stringWriter ); <=======()
    //…
    Object test = xmlObject.getDocument(); <=======(**)

    if (test instanceof Document) {
    Document doc = (Document) test;
    //serialize doc…
    }
    }

    From the code (
    ),
    One element of query results is returned at each loop iteration.
    But from the code (),
    returned documents are the same for every loop iteration, and that document includes all resulting elements enclosed by ino:response even though the code (
    ) is in the loop.

    It is so strange to me. How can I convert each TXMLObject result to dom object model separately not as a merged form?

    Please help me.


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


  • 2.  RE: TXMLObject, TXQuery & getDocument()

    Posted Mon August 09, 2004 01:08 PM

    The xmlObject.getDocument() call return the entire xml document, i.e. the Tamino response document. You need to change this to xmlObject.getElement(). This returns a DOM Element object representing an individual document within the result set.

    Hope this helps.

    Stuart Fyffe-Collins
    Software AG (UK) Ltd.


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