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.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  Xquery problem

    Posted 07/27/07 06:06 AM

    Hi
    I got a problem in writing an xquery. I gave a simple example to address it.
    Assume there is a dtd like this:

    and the conforming xml document is the following:

    George Good night 2006 Ocean Thirteen 2007 Brad Ocean Thirteen 2007 Mr Smith 2007

    Is it possible to write a xquery that gets all the movie information of the actor whose name is “george”?
    I was frustrated about this for a long time, and really need help!


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: Xquery problem

    Posted 07/27/07 06:21 AM

    I don’t understand your document, actually…the tags are not associated with any tags. If the tag was inside the element, then you could find the s with selected s inside them (so the tag would be repeated for each movie George was in):
    George

    Or, technically, you can put the tags inside the element:
    George etc

    For the context given, I would suggest the first structure.


    #API-Management
    #Tamino
    #webMethods


  • 3.  RE: Xquery problem

    Posted 07/27/07 06:30 AM

    Thank you for your reply.
    I didn’t type the whole dtd correctly.
    here it is:





    and with this DTD, “name” and “movie” do have an association.
    My question is, given such a DTD and its xml document, that can I write an xquery to get what I want? thank you again!


    #Tamino
    #API-Management
    #webMethods


  • 4.  RE: Xquery problem

    Posted 07/27/07 06:32 AM

    Thank you for your reply.
    I didn’t type the whole dtd correctly.
    here it is:





    and with this DTD, “name” and “movie” do have an association.
    My question is, given such a DTD and its xml document, that can I write an xquery to get what I want? thank you again!


    #Tamino
    #webMethods
    #API-Management


  • 5.  RE: Xquery problem

    Posted 07/27/07 06:35 AM

    Failed again.
    I have to change the present format of DTD:

    actor-> (name, movie*)*
    name->pcdata
    movie->(title,year)
    title->pcdata
    year->pcdata


    #Tamino
    #webMethods
    #API-Management


  • 6.  RE: Xquery problem

    Posted 07/30/07 10:50 PM


  • 7.  RE: Xquery problem

    Posted 07/31/07 12:38 PM

    I used this query on the following documents:

    In this example I would usually expect the data to be documents of the form:


    #webMethods
    #Tamino
    #API-Management


  • 8.  RE: Xquery problem

    Posted 07/31/07 07:08 PM

    Something is getting lost in this posting. I don’t understand what appears to be an empty DTD:

    Jason - perhaps you could post your DTD as an attachment to help us understand what you are trying to achieve?


    #webMethods
    #Tamino
    #API-Management


  • 9.  RE: Xquery problem

    Posted 08/02/07 07:49 AM

    Thank you for your concern.
    I have edited my DTD one the first post.


    #Tamino
    #webMethods
    #API-Management


  • 10.  RE: Xquery problem

    Posted 08/02/07 02:39 PM

    Normally, you would assume that a name and the corresponding movies are grouped under a common XML tag, as the previous replies suggest, or that you have a separate document for each actor. Then you could query:

    
    for $doc in collection("ino:etc") 
    where $doc/root/name="George"
    return $doc/root/movie

    Now, with the modelling you currently have, a query such as

    
    for $doc in collection("ino:etc") 
    let $name:=$doc/root/name[.="George"]
    let $name1:=$doc/root/name[. >> $name][1]
    return $doc/root/movie[. >> $name and . << $name1]

    does the job. But I really recommend changing the DTD

    Best regards

    Harald

    regards

    Harald


    #webMethods
    #Tamino
    #API-Management