So you want created if modified does not exist? Well depending on the
structure of your data, there are a couple of options...
If your 'Dates' element always has just 'created' and/or 'modified'
dates in the order you describe, then you could use -
let $find-year := 1999 return
count(
/Dates/Date[last()][year-from-date(@value) eq $find-year]
)
Otherwise, if you need to be more specific because your 'Dates'
element structure is more complex than you describe here (assuming
that modified always follows created) -
let $find-year := 1999 return
count(
/Dates/Date[@type =
('modified','created')][last()][year-from-date(@value) eq $find-year]
)
Cheers Adam.
2009/6/30 PencilEd <
gstewart@...>:
>
> I may have 2 resources with the following 'Dates'
>
> 1)
> <Dates>
> <Date type='created' value='2008-03-05'>
> <Date type='modified' value='2009-01-10'>
> </Dates>
>
> 2)
> <Dates>
> <Date type='created' value='2008-02-12'>
> </Dates>
>
> I'm wanting to get a count of the records modified in a given year - of
> course... if no Date of type='modified' exists then the Date of
> type='created' should be counted.
>
> So - the 2 records above would give 1 for 2008 (#2) and 1 for 2009 (#1,
> since it was last modified in 2009).
>
> I'm using the following:
>
> {count(collection($my_collection)/Dates/Date[@type =
> 'created']/@value[year-from-date(.) >= $year and year-from-date(.) < $year +
> 1])}
>
> Is there a way to do something like [@type = {if exists(@type = 'modified')
> then 'modified' else 'created'}]?
> --
> View this message in context:
http://www.nabble.com/Predicate-change-if-attribute-exists...--tp24276541p24276541.html> Sent from the exist-open mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Exist-open mailing list
>
Exist-open@...
>
https://lists.sourceforge.net/lists/listinfo/exist-open>
--
Adam Retter
eXist Developer
{ United Kingdom }
adam@...
irc://irc.freenode.net/existdb
------------------------------------------------------------------------------
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open