[ignore] update jquery reference

[ignore] update jquery reference

svn path=/trunk/eXist/; revision=13358

xquery version "1.0";
(: $Id$ :)
(:
    eXist & OpenId login forms.
:)

declare option exist:serialize "method=xhtml media-type=text/html indent=yes omit-xml-declaration=no";

		<link rel="stylesheet" type="text/css" href="css/eXist.css" />

		<link rel="stylesheet" type="text/css" href="../scripts/yui/grids/grids-min.css" />

		<link rel="stylesheet" href="../scripts/openid-selector/css/openid.css" />

Log in with a eXist-db account

				<form action="j_security_check" method="post" id="login_native">

					<input type="hidden" name="return_to" value="{session:encode-url(request:get-uri())}" />

Enter your account info:

					<fieldset style="padding: 0">
						<legend></legend>

Username:

									<input type="text" name="j_username" maxlength="15" value="" style="padding: .2em; border: 1px solid #789"/>

Password:

									<input type="password" name="j_password" maxlength="32" style="padding: .2em; border: 1px solid #789"/>

									<input type="submit" name="login" value="Sign-In"/>

					</fieldset>
				</form>

Log in with a OpenID account

				<form action="{request:get-context-path()}/openid" method="get" id="openid_form">
					<input type="hidden" name="action" value="verify" />

					<input type="hidden" name="return_to" value="{session:encode-url(request:get-uri())}" />

					<fieldset>
						<legend></legend>

Please click your account provider:

							<input id="openid_identifier" name="openid_identifier" type="text" value="http://" />
							<input id="openid_submit" type="submit" value="Sign-In"/>

OpenID is service that allows you to log-on to many different websites using a single indentity.
							Find out more about OpenID and how to get an OpenID enabled account.

					</fieldset>
				</form>

Copyright © 2010 eXist-DB All rights reserved.


Complete BaseX Fetch Module signatures.

Complete BaseX Fetch Module signatures.

xquery version "3.0";
(:~
: BaseX Database Module functions
:
: @see http://docs.basex.org/wiki/Fetch_Module
:)
module namespace fetch = "http://basex.org/modules/fetch";

import module namespace a = "http://reecedunn.co.uk/xquery/annotations" at "res://reecedunn.co.uk/xquery/annotations.xqy";

declare %a:since("basex", "7.6") function fetch:binary($uri as xs:string) as xs:base64Binary external;
declare %a:since("basex", "7.6") function fetch:text($uri as xs:string) as xs:string external;
declare %a:since("basex", "7.6") function fetch:text($uri as xs:string, $encoding as xs:string) as xs:string external;
declare %a:since("basex", "8.5") function fetch:text($uri as xs:string, $encoding as xs:string, $fallback as xs:boolean) as xs:string  external;
declare %a:since("basex", "8.0") function fetch:xml($uri as xs:string) as document-node() external;
declare %a:since("basex", "8.0") function fetch:xml($uri as xs:string, $options as map(*)? (: $options [8.0] as map(*) [8.6.7] as map(*)? :)) as document-node() external;
declare %a:since("basex", "9.0") function fetch:xml-binary($data as xs:base64Binary) as document-node() external;
declare %a:since("basex", "9.0") function fetch:xml-binary($data as xs:base64Binary, $options as map(*)?) as document-node() external;
declare %a:since("basex", "7.6") function fetch:content-type($uri as xs:string) as xs:string external;

xquery version "3.0";
(:~
: BaseX Database Module functions
:
: @see http://docs.basex.org/wiki/Fetch_Module
:)
module namespace db = "http://basex.org/modules/fetch";

import module namespace a = "http://reecedunn.co.uk/xquery/annotations" at "res://reecedunn.co.uk/xquery/annotations.xqy";


Path name error fixed

Path name error fixed

xquery version "1.0" encoding "UTF-8";

declare option exist:serialize "method=html media-type=text/html indent=no";

declare variable $page-title as xs:string := "Upload example process (binary file)";

let $field-name as xs:string := "file-upload"
let $store-collection as xs:anyURI := xs:anyURI('/db/apps/exist-book/data')

let $upload-name as xs:string := request:get-uploaded-file-name($field-name)
let $upload-size as xs:double := request:get-uploaded-file-size($field-name)
let $stored-file as xs:string? := xmldb:store($store-collection, $upload-name,
  request:get-uploaded-file-data($field-name), 'application/octet-stream')

return

  			<meta HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8"/>
  			<title>{$page-title}</title>

{$page-title}

Stored: {$stored-file}

Original name: {$upload-name}

Size: {$upload-size}

MIME type: {xmldb:get-mime-type(xs:anyURI($stored-file))}

xquery version "1.0" encoding "UTF-8";

declare option exist:serialize "method=html media-type=text/html indent=no";

declare variable $page-title as xs:string := "Upload example process (binary file)";

let $field-name as xs:string := "file-upload"
let $store-collection as xs:anyURI := xs:anyURI('/db/apps/eXist-book/data')

let $upload-name as xs:string := request:get-uploaded-file-name($field-name)
let $upload-size as xs:double := request:get-uploaded-file-size($field-name)
let $stored-file as xs:string? := xmldb:store($store-collection, $upload-name,
  request:get-uploaded-file-data($field-name), 'application/octet-stream')

return

  			<meta HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8"/>
  			<title>{$page-title}</title>

{$page-title}

Stored: {$stored-file}

Original name: {$upload-name}

Size: {$upload-size}

MIME type: {xmldb:get-mime-type(xs:anyURI($stored-file))}


make dsc optional (don't error out if not present)

module namespace eadxq = "http://www.library.emory.edu/xquery/eadxq";

declare namespace text = "http://exist-db.org/xquery/text";

import module namespace phrase="http://www.library.emory.edu/xquery/phrase" at
    "xmldb:exist:///db/xquery-modules/phrase.xqm";

(:
: xquery functions for EAD finding aid documents
:)

(:~
: return all elements necessary to build a table of contents for the finding aid
:
: @param ead root document element
: @return toc element with selected ead sections and headers
:)
declare function eadxq:toc($ead as element(ead),
  			   $keyword as xs:string?,
  			   $phrase as xs:string?) as node() {
  let $archdesc := $ead/archdesc
  return <toc>
	   <ead>{$ead/@id}
		<name>
			{string($archdesc/did/origination/persname)}
			{string($archdesc/did/origination/corpname)}
			{string($archdesc/did/origination/famname)}
		</name>
		<eadheader>
			<filedesc>
              <titlestmt>{$ead/eadheader/filedesc/titlestmt/titleproper}</titlestmt>
            </filedesc>
		</eadheader>
		<archdesc>
		  <did>
	            {$archdesc/did/unittitle}
                    {eadxq:hits($archdesc/did, $keyword, $phrase)}
		  </did>
	     <collectiondescription>
               {eadxq:hits(($archdesc//bioghist, $archdesc//scopecontent), $keyword, $phrase)}
             </collectiondescription>
             <controlaccess>
               {eadxq:hits($archdesc//controlaccess, $keyword, $phrase)}
             </controlaccess>

		  <index>
	    	    {$archdesc/index/@id}
                    {$archdesc/index/head}
                    {eadxq:hits($archdesc/index, $keyword, $phrase)}
	          </index>

			<dsc>
				{$archdesc/dsc/head}
                          {eadxq:hits($archdesc/dsc, $keyword, $phrase)}

			{for $c in $archdesc/dsc/c01[@level='series']
			 return <c01>
				 {$c/@id}
		            	 {$c/@level}
	                        {eadxq:hits($c, $keyword, $phrase)}
				 {if (exists($c/c02)) then <c02/> else ()}
				<did>
					{$c/did/unitid}
					{$c/did/unittitle}
   					{$c/did/physdesc}
				</did>
  			  </c01>}
	    	</dsc>
		  </archdesc>
	   </ead>
  </toc>
};

(:~
: shortcut version of toc function without keyword or phrase
:)
declare function eadxq:toc($ead as element(ead)) as node() {
 eadxq:toc($ead, "", "")
};

(:~
: shortcut version of toc function without phrase
:)
declare function eadxq:toc($ead as element(ead), $keyword as xs:string) as node() {
 eadxq:toc($ead, $keyword, "")
};

(:~
: convenience function to call the appropriate content function depending on element type
:)
declare function eadxq:content($element as element(),
  			       $keyword as xs:string,
			       $phrase as xs:string) as node() {
(: filter on keyword to get full-text higlighting :)
 let $el := (if ($keyword != "" and exists($element[. |= $keyword])) then
     $element[. |= $keyword]
    else $element)
 return
  if (name($el) = 'ead') then
  eadxq:content-ead($el, $keyword, $phrase)
 else
  eadxq:content-c($el, $phrase)
};

declare function eadxq:content($element as element()) as node() {
  eadxq:content($element, "", "")
};

(:~
: xml needed for content page when element is ead (not entire ead)
:)
declare function eadxq:content-ead($ead as element(ead),
	$keyword as xs:string,
	$phrase as xs:string) as node() {
	 <ead>
   		  {$ead/@id}
		  {phrase:tag-matches($ead/eadheader, $phrase)}
		  {phrase:tag-matches($ead/frontmatter, $phrase)}
		 <archdesc>
	 	{phrase:tag-matches($ead/archdesc/*[not(self::dsc)], $phrase)}
		{for $dsc in $ead/archdesc/dsc return eadxq:dsc($dsc, $keyword, $phrase)}
	 </archdesc>
	</ead>
};

(: FIXME: would header or frontmatter ever be displayed / need highlighting ? :)

(:~
: c-series node
: returns ancestor c01 id to allow highlighting context in TOC
:)
declare function eadxq:content-c($el as element(), $phrase as xs:string) as node() {
  <ead>
    {phrase:tag-matches($el, $phrase)}
    {for $parent in  $el/ancestor::c01
    return <parent id="{$parent/@id}"/> }
  </ead>
};

declare function eadxq:dsc($dsc as element(dsc),
	$keyword as xs:string,
	$phrase as xs:string) as node()* {
   for $d in $dsc
   return <dsc>
			{$d/@*}
		   	{$d/head}
		   {phrase:tag-matches($d/c01[@level != 'series'], $phrase)}
		   {for $c01 in $d/c01[c02 or @level='series']
		    return <c01>
		      {$c01/@*}
		      {$c01/did}
        	      {eadxq:hits($c01, $keyword, $phrase)}
		      {for $c02 in $c01/c02[@level='subseries']
			return <c02>
			 	 {$c02/@*}
				 {$c02/did}
			     {for $c03 in $c02/c03[c04]
				return <c03>
				 {$c03/@*}
				 {$c03/did}
		       </c03> }
	      </c02> }
	    </c01> }
    </dsc>
};

declare function eadxq:dsc($dsc as element(dsc)) as node()* {
    eadxq:dsc($dsc, "", "")
};

declare function eadxq:hits($el as element()*,
			    $keyword as xs:string,
			    $phrase as xs:string) as node() {
    <hits>{
     sum(eadxq:keyword-count($el, $keyword) + phrase:count($el, $phrase))
     }
   </hits>
};

declare function eadxq:keyword-count($el as element()*,
				     $keyword as xs:string) as xs:int {
    if ($keyword = '') then	0
    else
       sum(for $matchel in ($el)[. |= $keyword]
       return text:match-count($matchel))
};

module namespace eadxq = "http://www.library.emory.edu/xquery/eadxq";

declare namespace text = "http://exist-db.org/xquery/text";

import module namespace phrase="http://www.library.emory.edu/xquery/phrase" at
    "xmldb:exist:///db/xquery-modules/phrase.xqm";

(:
: xquery functions for EAD finding aid documents
:)

(:~
: return all elements necessary to build a table of contents for the finding aid
:
: @param ead root document element
: @return toc element with selected ead sections and headers
:)
declare function eadxq:toc($ead as element(ead),
  			   $keyword as xs:string?,
  			   $phrase as xs:string?) as node() {
  let $archdesc := $ead/archdesc
  return <toc>
	   <ead>{$ead/@id}
		<name>
			{string($archdesc/did/origination/persname)}
			{string($archdesc/did/origination/corpname)}
			{string($archdesc/did/origination/famname)}
		</name>
		<eadheader>
			<filedesc>
              <titlestmt>{$ead/eadheader/filedesc/titlestmt/titleproper}</titlestmt>
            </filedesc>
		</eadheader>
		<archdesc>
		  <did>
	            {$archdesc/did/unittitle}
                    {eadxq:hits($archdesc/did, $keyword, $phrase)}
		  </did>
	     <collectiondescription>
               {eadxq:hits(($archdesc//bioghist, $archdesc//scopecontent), $keyword, $phrase)}
             </collectiondescription>
             <controlaccess>
               {eadxq:hits($archdesc//controlaccess, $keyword, $phrase)}
             </controlaccess>

		  <index>
	    	    {$archdesc/index/@id}
                    {$archdesc/index/head}
                    {eadxq:hits($archdesc/index, $keyword, $phrase)}
	          </index>

			<dsc>
				{$archdesc/dsc/head}
                          {eadxq:hits($archdesc/dsc, $keyword, $phrase)}

			{for $c in $archdesc/dsc/c01[@level='series']
			 return <c01>
				 {$c/@id}
		            	 {$c/@level}
	                        {eadxq:hits($c, $keyword, $phrase)}
				 {if (exists($c/c02)) then <c02/> else ()}
				<did>
					{$c/did/unitid}
					{$c/did/unittitle}
   					{$c/did/physdesc}
				</did>
  			  </c01>}
	    	</dsc>
		  </archdesc>
	   </ead>
  </toc>
};

(:~
: shortcut version of toc function without keyword or phrase
:)
declare function eadxq:toc($ead as element(ead)) as node() {
 eadxq:toc($ead, "", "")
};

(:~
: shortcut version of toc function without phrase
:)
declare function eadxq:toc($ead as element(ead), $keyword as xs:string) as node() {
 eadxq:toc($ead, $keyword, "")
};

(:~
: convenience function to call the appropriate content function depending on element type
:)
declare function eadxq:content($element as element(),
  			       $keyword as xs:string,
			       $phrase as xs:string) as node() {
(: filter on keyword to get full-text higlighting :)
 let $el := (if ($keyword != "" and exists($element[. |= $keyword])) then
     $element[. |= $keyword]
    else $element)
 return
  if (name($el) = 'ead') then
  eadxq:content-ead($el, $keyword, $phrase)
 else
  eadxq:content-c($el, $phrase)
};

declare function eadxq:content($element as element()) as node() {
  eadxq:content($element, "", "")
};

(:~
: xml needed for content page when element is ead (not entire ead)
:)
declare function eadxq:content-ead($ead as element(ead),
	$keyword as xs:string,
	$phrase as xs:string) as node() {
	 <ead>
   		  {$ead/@id}
		  {phrase:tag-matches($ead/eadheader, $phrase)}
		  {phrase:tag-matches($ead/frontmatter, $phrase)}
		 <archdesc>
	 	{phrase:tag-matches($ead/archdesc/*[not(self::dsc)], $phrase)}
		{eadxq:dsc($ead/archdesc/dsc, $keyword, $phrase)}
	 </archdesc>
	</ead>
};

(: FIXME: would header or frontmatter ever be displayed / need highlighting ? :)

(:~
: c-series node
: returns ancestor c01 id to allow highlighting context in TOC
:)
declare function eadxq:content-c($el as element(), $phrase as xs:string) as node() {
  <ead>
    {phrase:tag-matches($el, $phrase)}
    {for $parent in  $el/ancestor::c01
    return <parent id="{$parent/@id}"/> }
  </ead>
};

declare function eadxq:dsc($dsc as element(dsc),
	$keyword as xs:string,
	$phrase as xs:string) as node()* {
   for $d in $dsc
   return <dsc>
			{$d/@*}
		   	{$d/head}
		   {phrase:tag-matches($d/c01[@level != 'series'], $phrase)}
		   {for $c01 in $d/c01[c02 or @level='series']
		    return <c01>
		      {$c01/@*}
		      {$c01/did}
        	      {eadxq:hits($c01, $keyword, $phrase)}
		      {for $c02 in $c01/c02[@level='subseries']
			return <c02>
			 	 {$c02/@*}
				 {$c02/did}
			     {for $c03 in $c02/c03[c04]
				return <c03>
				 {$c03/@*}
				 {$c03/did}
		       </c03> }
	      </c02> }
	    </c01> }
    </dsc>
};

declare function eadxq:dsc($dsc as element(dsc)) as node()* {
    eadxq:dsc($dsc, "", "")
};

declare function eadxq:hits($el as element()*,
			    $keyword as xs:string,
			    $phrase as xs:string) as node() {
    <hits>{
     sum(eadxq:keyword-count($el, $keyword) + phrase:count($el, $phrase))
     }
   </hits>
};

declare function eadxq:keyword-count($el as element()*,
				     $keyword as xs:string) as xs:int {
    if ($keyword = '') then	0
    else
       sum(for $matchel in ($el)[. |= $keyword]
       return text:match-count($matchel))
};