slightly convoluted query question

K

kishjeff

I'm still looking at this.. is this even possible?
I'd like to search a set of xml files
I want to skip all xml files that have a <client> element that
contains more than one <majortab> element,
but otherwise search for some elements with a @select attribute.

So I'm not sure how to skip the docs (or at least prevent them from
being included in the results) that have say:

<client>
<majortab ... /><majortab ... />
</client>

thanks for the hints.. still reading honestly!

Jeff
 
M

Martin Honnen

kishjeff said:
I'm still looking at this.. is this even possible?
I'd like to search a set of xml files
I want to skip all xml files that have a <client> element that
contains more than one <majortab> element,
but otherwise search for some elements with a @select attribute.

So I'm not sure how to skip the docs (or at least prevent them from
being included in the results) that have say:

<client>
<majortab ... /><majortab ... />
</client>

Well if you use XSLT or XQuery then you can certainly check whether
count(/client/majortab) > 1
With XSLT 2.0 or XQuery 1.0 you can load multiple XML source documents
using the collection function, see
http://www.saxonica.com/documentation/sourcedocs/collections.html for
instance how that works with Saxon 9.
 
J

Jeff Kish

Well if you use XSLT or XQuery then you can certainly check whether
count(/client/majortab) > 1
With XSLT 2.0 or XQuery 1.0 you can load multiple XML source documents
using the collection function, see
http://www.saxonica.com/documentation/sourcedocs/collections.html for
instance how that works with Saxon 9.
Yes, I have used the collection to load multiples, but I am not sure
how to exclude them from the processing based on whether or not they
have a certain element combination.

It is xquery, but a slightly older version... it is actually
ipsi-xq-1.3.4

I really like it.
Unfortunately it seems to be having a problem with starts-with
functions so I might have to cast about for another implementation if
I need to use that.

So I'm not sure how to structure the query so that the client/majortab
count > 1 go ahead v.s. skip if < =1

thanks
Jeff
 
M

Martin Honnen

Jeff said:
So I'm not sure how to structure the query so that the client/majortab
count > 1 go ahead v.s. skip if < =1

Well you could use the condition in a predicate when you select nodes e.g.

collection('file:///C:/someDir?select=*.xml')/foo/client[count(majortab)

or you could use a where condition

for $client in collection('file:///C:/someDir?select=*.xml')/foo/client
where count($client/majortab) > 1
return $client
 
K

kishjeff

Jeff said:
So I'm not sure how to structure the query so that the client/majortab
count > 1 go ahead v.s. skip if < =1

Well you could use the condition in a predicate when you select nodes e.g..

collection('file:///C:/someDir?select=*.xml')/foo/client[count(majortab)
 > 1]

or you could use a where condition

   for $client in collection('file:///C:/someDir?select=*.xml')/foo/client
   where count($client/majortab) > 1
   return $client

I'll try it, thanks much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top