Hello All,<br><br>I am new to this mailing list, as well as fairly new to XQuery and XPath (having learned it for a month or two). For the most part, I haven't had too much trouble editing an old XQuery document, until now.<br>
<br>I am trying to access the 'maxOccurs' attribute within the for-loop, where $ref is the 'ref' attribute, and return distinct <xf:bind> elements with no duplicate elements. However, I can't seem to set the $max variable properly using XPath functions, without getting an error. I imagine it must have something to do with setting/finding/using the current context. <br>
<br><br>The XQuery code looks like this:<br><br><br>if (exists($schema//xs:element[exists(@maxOccurs) and @maxOccurs != '1']))<br>then (<br> for $ref in distinct-values($schema//xs:element[exists(@maxOccurs) and @maxOccurs != '1' and @maxOccurs ne 'unbounded']/@ref)<br>
let $name := string($ref)<br> let $max := string($ref//following-sibling::maxOccurs)<br> let $index_max := ($max cast as xs:integer)<br> return<br> <xf:bind<br> id="{concat($name, '-add-trigger')}"<br>
nodeset="instance('views')/{$name}-add-trigger"<br> relevant="instance('save-data')//{$name}[{$index_min}]" /><br><br>)<br>else ()<br>};<br><br><br>and the XML schema code looks (very) roughly like this - and the only purpose of showing this is to help illustrate what I'd like to do:<br>
<br><xs:schema><br><br> <xs:element name="a"><br> <xs:complexType><br> <xs:sequence><br> <xs:element ref="e" maxOccurs="2" /><br> <xs:element ref="g" maxOccurs="3" /><br>
</xs:sequence><br> </xs:complexType><br> </xs:element><br><br> <xs:element name="b"><br>
<xs:complexType><br>
<xs:sequence><br>
<xs:element ref="j" maxOccurs="2" /><br>
<xs:element ref="g" maxOccurs="3" /><br>
</xs:sequence><br>
</xs:complexType><br>
</xs:element><br><br></xs:schema><br><br><br>Can someone show me the proper way to access the maxOccurs attribute from the ref attribute, and/or provide me with a link that can help me understand this situation a little more?<br>
<br>Thanks much in advance!<br><br><br>~PJC<br>