XQuery to choose between attributes or none

A rather tough problem is what I’m facing at this moment.

We’ve got an element which has three forms of appearence.

The last version is most commen, but, if there’s more elements then only one can be primairy.

What I’m trying to do is build an xquery where I select both the element without an attribute and the element with the primairy value.

for $a in input()/book
return

<for $b in input()/article where $b/@book = $a/@id return $b[@attribute=“primairy”]

or

for $a in input()/book
return

<for $b in input()/article where $b/@book = $a/@id return $b

But somehow I would like to combine these two query’s.

Using the [@attribute!=“secundairy”] only gives back primairy.

Does this work for you?

for $a in input()/book, $b in input()/article
where $b/@book = $a/@id
and $b/@attribute = “primairy”
or not($b/@attribute)
return $b