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.  Display TAGs with JSP

    Posted Fri December 07, 2001 09:19 AM

    Hello there,

    I’m verry new at JSP and Java. Installed Tomcat and the Telephone example from Tamino.
    All this works fine. What I really would like to display is only the XML starttags and not the content. F.ex. a pulldownlist with available XML tags.
    Someone who can help? We need to know whats possible so we can decide wich programming language we will use for accessing Tamino.
    Thanks in advance!

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
    <%@ page language=“java” contentType=“text/html” %>
    <%@ page import=“com.softwareag.tamino.API.dom.*” %>
    <%@ page import=“org.w3c.dom.Element” %>


    A simple Tamino access example with jsp


    <%
    TaminoClient myTC = new TaminoClient(“http://localhost/tamino/test/Telephone”);
    myTC.setPageSize(5);
    TaminoResult myTR = myTC.query( “Telephone[@ino:id=1]” );
    while (myTR.hasMoreElements()) {
    Element myElement = myTR.getNextElement();
    %>
    <%=myElement.toString()%>
    <% } %>
    Done!


    :confused:


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


  • 2.  RE: Display TAGs with JSP

    Posted Fri December 07, 2001 09:38 AM

    Do you mean get the Tagname instead of a string representation of the the element?

    not <%=myElement.toString()%>
    but
    <%=myElement.getNodeName()%>


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


  • 3.  RE: Display TAGs with JSP

    Posted Fri December 07, 2001 11:13 AM

    Almost! What I need is the starttag of each XML element within the resultset.

    Below the result in HTML. As you can see it displays the first NODE and the NodeName as you told me.

    What I want is a list with this:

    Telephone
    LoginName
    PassWord
    Lastname
    Firstname

    OK?

    Result:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>


    A simple Tamino access example with jsp



    Wehlmann125Wehlmann124WehlmannAnton<Date_of_Birth>02.01.1945</Date_of_Birth><Company_Name>Deutsche Bank</Company_Name>HerrWehlmann124@web.deSeitersweg 200Darmstadt64287Germany06150-4140406150-896177

    Telephone

    Done!


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


  • 4.  RE: Display TAGs with JSP

    Posted Fri December 07, 2001 01:34 PM

    Hi there,

    TaminoResult myTR = myTC.query(“Telephone [LoginName~="W*"]”);
    /* cast for enumeration /
    Enumeration e = myTR;

    if ( !e.hasMoreElements() )
    out.println("Query :Telephone[LoginName~="W
    "] No elements found !" );
    else
    while( e.hasMoreElements() ){
    Element el=(Element)e.nextElement();
    for ( int x = 0; x < 10; x++ ) {
    String name = el.getElementsByTagName(“*”).item(x).getNodeName();
    out.println(name);
    }
    }


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


  • 5.  RE: Display TAGs with JSP

    Posted Fri December 07, 2001 01:38 PM

    The For loop
    for ( int x = 0; x < 10; x++ ) {

    contains x<10 so it will only do the first 10 elements.

    I want to print out all the elements. I guess there’s a .count method. I’ll try to find it but if anyone could give a tip I will be verry pleased.

    Regards,
    Francis


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


  • 6.  RE: Display TAGs with JSP

    Posted Fri December 07, 2001 03:13 PM

    getElementsByTagName() returns a NodeList object, and the NodeList has a getLength() method to tell you how many Nodes it contains.

    So if you use two steps:

    Element el=(Element)e.nextElement();
    NodeList myList = el.getElementsByTagName(*);
    for ( int x = 0; x < myList.getLength(); x++ ) {
    String name = myList.item(x).getNodeName();
    out.println(name);
    }
    }
    it should work.

    [This message was edited by Bill Leeney on 07 Dec 2001 at 15:07.]


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


  • 7.  RE: Display TAGs with JSP

    Posted Mon December 10, 2001 08:55 AM

    It works, thanks.
    By the way: ther’re quotes needed:
    NodeList myList = el.getElementsByTagName();
    should be
    NodeList myList = el.getElementsByTagName("
    ");

    Francis


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