return an Element of specific ID

I have one XML Document. It has many Elements.
Some of them have an attribute, which has the type of XS:ID, so it’s unique pro document.

I would like the have the XQuery to get the
Element, which has the attribute value ‘X’

The value for ‘X’ is given.
eN = ElementName is not given
aN = AttributeName is not given


queryString = "for $b in input()/labDevices//eN[aN=’"+X+"’] ";

queryString += “return $b”;

What is the correct syntax to get the element,
which has the attribute (ID) value for ‘X’ ?

Thank you!
Aykut

Hello Aykut,

would something like the following solve your query:

for $x in input()/labDevices//@*
where $x='X’
return $x/…

This looks for all attributes with a value of ‘X’ and returns the parent element of that value.

Kind regards,

Stuart Fyffe-Collins
Software AG (UK) Ltd.

[within java code]
queryString = "for $x in input()/labDevices//@* “;
queryString += “where $x=’”+typeID+”’ ";
queryString += “return $x/…”;

[while running]
for $x in input()/labDevices//@* where $x=‘v1s19’ return $x/…

I get a “Runtime type exception” Error. (TQuery Exception)

Hello Aykut,

I tried Stuart’s XQuery with an old “labDevices” document that I had from a previous test (which is stored in ino:etc), and it worked fine.

Could you please post your schema and the document which is giving the error?

(Perhaps we should also confirm which Tamino version you are using - 4.1.4.1 ?)

Thanks,
Trevor.

Hey Trevor,

thanks I already solved the problem with
a little bit more coding.

Aykut

PS : I have the Tamino Version 4.1.4.1