Querying attribute of an element using ~= instead of =

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

~=‘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.

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?

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

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