« Return to Thread: Predicate change if attribute exists...?

Predicate change if attribute exists...?

by PencilEd :: Rate this Message:

Reply to Author | View in Thread

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'}]?

 « Return to Thread: Predicate change if attribute exists...?