|
From: Christopher T. <chr...@ca...> - 2012-03-13 09:58:43
|
Hi Martin,
I'm not using <listPerson> as I believe <person> can be used directly in
<particDesc>. Each entry in the annotated bibliography I'm working on is
about a single author so I'll only have one <person> element per
header. An extra slash after the $doc variable doesn't seem to make any
difference either, unfortunately.
I find I can get the code working in my main query, but as soon as I
move it to the module and call it using { bibl:dob($doc) } it no longer
works. However, functions declared in bibl.xqm do work when they
contain no XQuery expressions but only HTML and boilerplate text. This
leads me to believe there's a problem with passing the argument $doc to
the function held in bibl.xqm.
This slightly more sophisticated version below returns dates of birth as
a FLWOR expression within the main query. But, declared as a function
in the module and called in the main query it no longer returns anything.
declare function bibl:dob($doc) {
let $dob :=
$doc/tei:teiHeader/tei:profileDesc/tei:particDesc/tei:person/tei:birth/text()
let $dod :=
$doc/tei:teiHeader/tei:profileDesc/tei:particDesc/tei:person/tei:death/text()
let $dob-separator := ' - '
return
if (exists($dod)) then (<p>{concat($dob, $dob-separator,
$dod)}</p>)
else (<p>{concat($dob, $dob-separator)}</p>)
};
Any other ideas? Thanks for your help so far.
Cheers,
Chris
On 13/03/12 1:51 AM, Martin Holmes wrote:
> Hi there,
>
> Should your path include <listPerson>?
>
> tei:teiHeader/tei:profileDesc/tei:particDesc/tei:listPerson/tei:person/...
>
>
> Or do you need an extra slash after the doc root:
>
> let $dob := $doc//tei:teiHeader
>
> (the document root is not necessarily the same as the root XML element.)
>
> Cheers,
> Martin
>
> On 12-03-11 10:26 PM, Christopher Thomson wrote:
>> Thanks for your reply. My bibl.xqm module starts like this:
>>
>> xquery version "1.0";
>>
>> module namespace bibl = "www.example.org.nz/ns/xquery/bibl";
>>
>> declare namespace bibl = "www.example.org.nz/ns/xquery/bibl";
>> declare namespace exist = "http://exist.sourceforge.net/NS/exist";
>> declare namespace tei = "http://www.tei-c.org/ns/1.0/";
>>
>> I then import this module into the query where the function is called. I
>> think declaring the bibl namespace in the module is unnecessary, but
>> I've been trying various things to get this working, and it doesn't
>> produce an error.
>>
>> Cheers,
>> Chris
>>
>>
>> On 12/03/12 12:16 PM, Martin Holmes wrote:
>>> Do you have the tei: prefix correctly declared in your bibl.xqm module?
>>>
>>> Cheers,
>>> Martin
>>>
>>> On 12-03-11 12:27 PM, Christopher Thomson wrote:
>>>> I am creating an module to hold commonly used XQuery expressions as
>>>> functions. $doc defines the document in my collection of TEI files,
>>>> and
>>>> the following returns a date of birth in the desired way:
>>>>
>>>> *<div id="sidebar" class="span-6">
>>>> <h3><b>{$fullname}</b></h3>
>>>>
>>>> let $dob :=
>>>> $doc/tei:teiHeader/tei:profileDesc/tei:particDesc/tei:person/tei:birth
>>>> return<p>{$dob/text()}</p>
>>>> </div>*
>>>>
>>>> Next, I move this code to a function in a module in the namespace
>>>> bibl.
>>>> The above div becomes:
>>>>
>>>> *<div id="sidebar" class="span-6">
>>>> <h3><b>{$fullname}</b></h3>
>>>>
>>>> { bibl:dob($doc) }
>>>> </div>*
>>>>
>>>> The function is declared in the bibl.xqm module thus:
>>>>
>>>> *declare function bibl:dob($doc) {
>>>> let $dob :=
>>>> $doc/tei:teiHeader/tei:profileDesc/tei:particDesc/tei:person/tei:birth
>>>> return<p>{$dob/text()}</p>
>>>> };*
>>>>
>>>> This arrangement does not return the date of birth to the resulting
>>>> web
>>>> page. Does anyone see where the error is here? I have assumed the $doc
>>>> argument will be passed from the main page to the function in the bibl
>>>> module. 'bibl' is imported into the main page and seems to be defined
>>>> correctly as a module.
>>>>
>>>> Thanks,
>>>> Chris
>>>>
|