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

Using X-query to retrieve information from collection

  • 1.  Using X-query to retrieve information from collection

    Posted Sat October 08, 2005 02:17 AM

    We’ve got multiple schema’s defined within a collection.
    With XQuery I have no problem retrieving data from multiple schema’s like this example shows

    for $a in input()/article
    return

    {for $b in input()/book where $b/@id = $a/article/@book return $b}

    {$a}

    But I need the same sort of functionality from an X-Query, but don’t know how.


    #webMethods
    #Tamino
    #API-Management


  • 2.  RE: Using X-query to retrieve information from collection

    Posted Mon October 10, 2005 08:39 PM

    I don’t believe you can do this with X-Query; it only can process one doctype at a time.

    In previous versions of Tamino you could define a node within the schema of one doctype that represented a link to a document (or node within a document) of a second doctype, and this allowed an X-Query to retrieve parts of related documents within a single query. However, while I don’t remember this functionality being dropped I can’t find any documentation for it in the current version. (I may just be looking in the wrong place.)

    But I don’t understand your your assertion that you need this in X-Query. X-Query is just there for “backwards compatibility”, ie., so applications written for earlier Tamino versions will still work. If you’re trying to add new functionality you should be using XQuery in any case.


    #Tamino
    #API-Management
    #webMethods


  • 3.  RE: Using X-query to retrieve information from collection

    Posted Wed October 12, 2005 10:56 AM

    Okey, thanks for the response.

    Currently I’m using a browsing cursor to retrieve a paged result. Is it possible to just replace the X-Query with XQuery ? Or do I need to make alterations?

    cursor = new BrowseCursor(Convert.ToUInt16(ddResultSize.SelectedValue),_xql.ToString(),sl);

    where the _xql.ToString() bit is the X-Query

    Here is the part of the function that handles the response from tamino:

    public void ParseResult(System.IO.Stream result) {

    		next = 1;
    previous  = 1;
    position = 0;
    quantity = 0;
    
    try {
    XmlTextReader  rdr = new XmlTextReader(result);
    rdr.WhitespaceHandling = WhitespaceHandling.None;
    rdr.Namespaces = false;
    
    while  (rdr.Read()) {
    if (rdr.NodeType == XmlNodeType.Element) {
    switch(rdr.Name) {
    case  "xql:query":
    rdr.Read();
    xpath = rdr.Value;
    break;
    case  "ino:message":
    returnvalue = rdr.GetAttribute("ino:returnvalue"); 
    break;
    case  "ino:messageline":
    rdr.Read();
    errortext  = rdr.Value; 
    break;
    case  "ino:messagetext":
    rdr.Read();
    errortext  = rdr.Value; 
    break;
    case  "xq:result"	 : 
    case  "xql:result"   :
    rdr.Read();
    
    docs = new System.Collections.ArrayList();
    if (singular) 
    {
    docs.Add(rdr.Value);
    }
    else 
    {
    doctype = rdr.Name;
    
    //								StringReader srdr = new StringReader(rdr.ReadOuterXml());
    //								XmlTextReader locrdr = new XmlTextReader(srdr);
    docs.Add(rdr.ReadOuterXml());
    
    while  (rdr.Name.Equals(doctype)) 
    {
    
    //									srdr = new StringReader(rdr.ReadOuterXml());
    //									locrdr = new XmlTextReader(srdr);
    docs.Add(rdr.ReadOuterXml());
    }
    }
    break;
    case  "ino:current":
    position = int.Parse(rdr.GetAttribute("ino:position"));
    quantity = int.Parse(rdr.GetAttribute("ino:quantity"));
    
    break;
    case "ino:next":
    next = int.Parse(rdr.GetAttribute("ino:position"));
    break;
    case "ino:prev": 						
    previous = int.Parse(rdr.GetAttribute("ino:position"));
    break;
    }
    }
    
    
    
    }
    
    }
    catch(Exception e) {
    Console.WriteLine(e.StackTrace);
    }
    finally {
    result.Close();
    }
    }
    

    }


    #webMethods
    #Tamino
    #API-Management