how to figure out, if an optional node is created

env: ino414 using either x-query or XQuery 4 Tamino
problem: how to get the information, if an optional node is created, because a node value exist. at this time i can only think of using the count() function and if gt 0 node exist and if 0 node does not exist.

example:

<tele_bill>
<call_types type=“local”> this node is optional

</call_types>
<call_types type=“national”>

</call_types>
<call_types type=“international”>

</call_types>
</tele_bill>

now the question: how can i figure out, if the customer has done international calls?

thanks in advance
Michael

seems to be straightforward: just ask for it. Tamino (or the indexing) should know if the node exists.

get customer with international calls:

X-Query:
…/customer[call_types/@type=“international] …
gives you customers with international calls

same in XQuery:
for $c in input()/customer
where $c/call_types/@type = “international”
return $c


Ask for international calls of a customer:
X-Query:
…/customer[id=”…" and call_types/@type="international] …
gives you a single customers with international calls. If nothing is returned, he has no international calls.

same in XQuery:
for $c in input()/customer
where $c/call_types/@type = “international” and $c/id= …
return $c


Tip:
Put a standard index on “type” in your schema.

regards,

Timm