Hello BaseX Staff,
I am trying to finish building a map of data I have been working on and am
nearly complete, but am stuck on trying to retrieve an elements value,
which should just be a single integer in string format.
The function doing the work:
declare function local:propGenerator($propList, $currID){
let $context := db:open($documentName)
let $ret := for $x at $pos in 1 to (xs:integer(count($propList) div 3))
let $mult := ($pos - 1) * 3
return
map:merge(($propsMap,
map:entry(concat("prop", $pos),
map{"xmi:type" : $propList[1 + $mult],
"xmi:id" : $propList[2 + $mult],
"name" : $propList[3 + $mult],
"lowerValue" : 1,
"upperValue" :
($context//packagedElement/[@xmi:id=$currID]/ownedAttribute/[@xmi:id=$propList[2
+ $mult]]/upperValue/[@value])
})))
return $ret
};
this function takes a list of strings, which come in triplets. The map is
nearly built except for the "lowerValue" and "upperValue" and I'm getting
an error I can't make sense of because of the line:
"upperValue" :
($context//packagedElement/[@xmi:id=$currID]/ownedAttribute/[@xmi:id=$propList[2
+ $mult]]/upperValue/[@value])
This search is going to be mirrored for the lowerValue once I get it
working. The value in the "upperValue" element should always exist, and
this should be unique because I am providing the IDs to narrow it down.
The error message I am getting:
[XPTY0019] ownedAttribute: node expected, array(*) found: [ false() ].
I tried wrapping the line in question with:
if (exists($context//packagedElement/...restOfQuery...)) then 2 else ()
and I got the same error. If I omit the line in question, the query works
so I am certain that line is the problem.
For additional info, I tried the search using an absolute path earlier and
I didn't have context so I am now using the context declaration.
The snippet of the XML being used:
<packagedElement xmi:type="uml:Class" xmi:id="
_18_5_2_4c1014b_1538502774996_709119_83315" name="Tape">
<ownedAttribute xmi:type="uml:Property" xmi:id="
_19_0_3e30194_1541527239959_149409_93200" name="
InformationAssuranceProperties" visibility="private">
<lowerValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="
_19_0_3e30194_1541527239960_849380_93202"/>
<upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="
_19_0_3e30194_1541527239960_70368_93203" value="*"/>
</ownedAttribute>
<!-- lots more ownedAttributes here... -->
</packagedElement>
Any advice here would be greatly appreciated, I am currently looking for
other solutions but figured asking here would be the most helpful.
Thank you,
Jordan Castillo