declare function local:getBasicTypes($productIds as xs:string*) as element(Product)* { (: remark: @identifier = $productIds acts like a SQL @identifier in $productIds :) collection("basicTypes/released")/Product[@identifier = $productIds] }; let $ids := ('PH3330L', 'PH3030CL') return{ for $bt in local:getBasicTypes($ids) return $bt/ProductInformation/Description }
Now let us create an index for the @identifier and retrieve the data using this index
create index "basictype_id" on fn:collection("basicTypes/released")/Product by @identifier as xs:string
declare function local:getBasicTypesByIndex($productIds as xs:string*) as element(Product)* { for $id in $productIds return index-scan('basictype_id', $id, 'EQ') }; let $ids := ('PH3330L', 'PH3030CL') return{ for $bt in local:getBasicTypesByIndex($ids) return $bt/ProductInformation/Description }
The result is the same for both:
<result> <Description>N-channel TrenchMOS logic level FET</Description> <Description>9657 Trench 7 (IMPULSE)</Description> </result>
Here is an example of creating an index using namespaces:
declare namespace cat = "urn:iso:std:iso:ts:29002:-10:ed-1:tech:xml-schema:catalogue"; create index "legacy_id" on fn:collection("legacyBasicTypes")/cat:catalogue by cat:item/cat:reference/@reference_number as xs:string
No comments:
Post a Comment