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.


#TechXchangePresenter
 View Only
Expand all | Collapse all

Querying attribute of an element using ~= instead of =

  • 1.  Querying attribute of an element using ~= instead of =

    Posted Wed May 08, 2002 11:48 PM

    Hi,

    if I have the following XML in my db



    San Francisco
    CA




    San Jose
    CA



    I know I can run the following x-query

    property[location/city=‘San Francisco’]

    or

    property[location/city~=‘San’]

    I can also run

    property[@type=‘4-Room-Apartment’]

    however, I CAN’T seem to run

    property[@type~=‘Apartment’]

    Is this not possible? Can ~= be used for elements and not their attributes?

    Any help would be appreciated.

    -Jose


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: Querying attribute of an element using ~= instead of =

    Posted Thu May 09, 2002 10:52 AM

    ~=‘Apartment’ will look for the individual word ‘Apartment’ in the string. The string ‘4-Room-Apartment’ does not contain this, the use of the hyphens is getting in the way. Try ~=‘*Apartment’ . This will return documents where the string ENDS in Apartment. Further to this you could use ~=‘Apartment’, which would return all documents where ‘Apartment’ occurs ANYWHERE in the string.


    #webMethods
    #API-Management
    #Tamino


  • 3.  RE: Querying attribute of an element using ~= instead of =

    Posted Tue June 11, 2002 03:33 PM

    question for you. I am trying to get a hold of the whole querying and i just can’t seem to get started. what is the rest of your code that you use. i look at other examples and you’re is so basic, …query this for this… what language is that and can you guide me?


    #API-Management
    #Tamino
    #webMethods


  • 4.  RE: Querying attribute of an element using ~= instead of =

    Posted Tue June 11, 2002 06:02 PM

    public static void fillVector(String docType, Vector docVector, String qStrXpath, String qStrValue, String qStrOpr) {
    try {
    BusinessDocumentWorkspace ws = new BusinessDocumentWorkspace(store);
    QueryContainer query = new QueryContainer(docType);
    query.add(new QueryElement(qStrXpath, qStrValue, qStrOpr));
    Cursor docCursor = ws.query(“qry”+docType, query);
    int counter = 0;
    while (docCursor.hasNext()) {
    BusinessDocument doc = (BusinessDocument)docCursor.next();
    counter++;
    System.out.println( docType+ ": " + doc.getDocumentId());
    docVector.add(doc);
    }
    docCursor.close();
    } catch (StoreException e) { e.printStackTrace(); }
    }


    this one a simple query code.

    But first you should create store and register doctype

    public static TaminoStore createStore( String url ) throws StoreException {
    tstore = new TaminoStore(url);
    return tstore;
    }

    url is your database like
    http://localhost/tamino/SampleDB”;


    protected static void RegisterDocType(String docType,String coll) {
    tstore.registerDoctypeCollection(docType,coll);
    }


    coll is your collection

    Brgs


    #webMethods
    #API-Management
    #Tamino


  • 5.  RE: Querying attribute of an element using ~= instead of =

    Posted Tue June 11, 2002 06:59 PM

    where do you put the x-query code? which file?


    #webMethods
    #API-Management
    #Tamino