(: Copyright (c)2006 Elsevier, Inc. : : Licensed under the Apache License, Version 2.0 (the "License"); : you may not use this file except in compliance with the License. : You may obtain a copy of the License at : : http://www.apache.org/licenses/LICENSE-2.0 : : Unless required by applicable law or agreed to in writing, software : distributed under the License is distributed on an "AS IS" BASIS, : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. : See the License for the specific language governing permissions and : limitations under the License. : : The use of the Apache License does not indicate that this project is : affiliated with the Apache Software Foundation. :) (:---------------------------------------------------------------------------------------------------------------- : : This script translates the W3C XPath F&O into xqDoc XML. : The script assumes the W3C XPath F&O html file found at : : http://www.w3.org/TR/2005/CR-xpath-functions-20051103/ : : has been loaded into the MarkLogic database with a URI value of : : 'xpath-nov2005' : : The generated xqDoc XML will be loaded into the 'xqdoc' collection with : a URI value of 'http://www.w3.org/2005/xpath-functions' : : This script translates the W3C XPath Functions and Operators specification (Nov 2005) : into xqDoc XML. There are certainly more recent drafts available for the W3C XPath Functions : and Operators specification and It would be a simple exercise to create : a similar translation script for more recent versions of the XPath Functions and : Operators specification. : : The May 2003 XQuery syntax is used in the script below. We are using the May 2003 XQuery : syntax since the XML database we are currently leveraging supports the May 2003 syntax. : :----------------------------------------------------------------------------------------------------------------:) define function get-text($item as item()) as xs:string* { if ($item instance of element()) then for $i in $item/node() return get-text($i) else if ($item instance of text()) then xs:string($item) else () } let $uri := "http://www.w3.org/TR/2005/CR-xpath-functions-20051103/" let $xml := { current-dateTime() } N/A http://www.w3.org/2005/xpath-functions This is the xqDoc XML version for the W3C XPath Functions and Operators Candidate Recommendation for November 2005, Copyright © 2005 W3C ® (MIT, ERCIM, Keio), All Rights Reserved.

The xqDoc version is a non-normative annotation (that may contain errors) and the W3C is not responsible for any content not found at the original URL. Since the information contained in the xqDoc XML version is only a subset of the W3C Candidate Recommendation, the W3C version should be consulted for the complete explanation.

This version of the W3C XPath Functions and Operators is not the most recent version available from the W3C.

All of the functions below contain helpful links (see:) that will lead the user to the particular function defined in the W3C XPath Functions and Operators Candidate Recommendation for November 2005. Please consult the latest version of the W3C XPath Functions and Operators specification for function definitions that may supersede these. {$uri} 03 November 2005 { let $seq := (for $x in doc("xpath-nov2005")//*:div[@class="div3"] [.//*:div[@class="exampleInner"] //*:div[@class="proto"] //*:code[@class="function"] /text()[starts-with(.,"fn:")]] order by xs:string($x/*:h4/*:a/@name) ascending return $x, for $y in doc("xpath-nov2005")//*:div[@class="div2"] [./*:h3/*:a/@name[starts-with(.,"func-")]] [.//*:div[@class="exampleInner"] //*:div[@class="proto"] //*:code[@class="function"] /text()[starts-with(.,"fn:")]] order by xs:string($y/*:h3/*:a/@name) ascending return $y, for $z in doc("xpath-nov2005")//*:div[@class="div1"] [./*:h2/*:a/@name[starts-with(.,"func-")]] [.//*:div[@class="exampleInner"] //*:div[@class="proto"] //*:code[@class="function"] /text()[starts-with(.,"fn:")]] order by xs:string($z/*:h2/*:a/@name) ascending return $z) for $i in $seq return { for $p in $i/*:p return get-text($p) } { for $a in distinct-values($i//*:div[@class="exampleInner"] /*:div[@class="proto"] //*:code[@class="arg"]) return {$a} } {concat($uri,"#",xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), ";;", if (starts-with(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-xpath-")) then substring-after(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-xpath-") else substring-after(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-") )} { if (starts-with(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-xpath-")) then {substring-after(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-xpath-")} else {substring-after(xs:string($i/(*:h4 | *:h3 | *:h2)/*:a/@name), "func-")} } { for $s in $i//*:div[@class="exampleInner"]/*:div[@class="proto"] return {concat("define function ", substring-after(xs:string(data($s)), "fn:"))} } } return xdmp:document-insert("http://www.w3.org/2005/xpath-functions", $xml, (), "xqdoc", 0, ())