In my collection ,there are some element like this:
one
one
one
one
onetwo
twoone
now ,I want to select these elements like this:
one
one
one
one
but not contain these two elements:
onetwo
twoone
what x-query sentence should i use.
how should i do to in order the tamino to filter the blanks?
I think it a long time ,but not find any way,
I try to delect the blanks in xml files ,then insert the instances,but there are too many files, so this method is to stupid, not realistic.
regards,
lisa
Hi Lisa,
For performance you can define a “text” index on the ‘test’ element. Regardless the query is
_xql=yourrootnode[.//test~=“one”]
which will find documents containing (~=) the word “one”.
Hope this helps.
Stuart Fyffe-Collins
Software AG (UK) Ltd.
Hi Stuart Fyffe-Collins,
thanks,
it works well,
In my mind ,i just think the [.//test~=“one”],
but [.//test~=“one”] also select the element like this:
two one ,
If have another better method?
If full-text query (~=) doesn’t suit here and you need to search for exact string (discarding leading and trailing whitespaces) then you’d better clear your data before loading it in Tamino.
To normalize existing data you can perform the following query:
update
for $x in input()/test
do replace $x/text() with normalize-space($x)
Theoretically you can use normalize-space() function to query data:
for $x in input()/test
where normalize-space($x) = “one”
return $x
But it won’t allow you to use indices and the query will be slow.
Hi Alexander and Stuart Fyffe-Collins?
Thanks for your help, I will choice one method to solve my problem base in my practice.
Would you like to teach me one method to use the help document efficient?Because I am not very familiar with the tamino ,especially X-query, And some API for it.Such as client API for jsricpt , and the methods’ write of MS DOM is not all the same as it(e.g. QueryResult.DOM.documentElement.xml, tomino Result object has DOM property?? ) .
Another question is string matching ( ingore the capital or lower letter in database).
I want to select all the elements(such as “database”," DataBase" , DATABASE) basing in the keywords “database”, what x-query should i use? I find no function in String Functions of xpath(3wc).
Thanks,
lisa
[This message was edited by lisa on 10 May 2003 at 12:01.]
Hi Lisa,
the ~= operator is not case-sensitive so performing
_xql=yourrootnode[.//test~=“one”]
will find documents with “one”, “One”, “ONE”, “ONe”, etc.
Best regards,
Stuart Fyffe-Collins
Software AG (UK) Ltd.