From: Christopher T. <chr...@ca...> - 2012-03-14 09:44:08
|
Hi, The double slash seems to make no difference I'm afraid. I've used the eXist sandbox to verify the function works if I point it directly at one of my TEI files. The result in the webpage is that I see the separator ' - ' but no values for date of birth or death, which also suggests that $doc doesn't make it to the function. Also, the functions you see that add CSS and header text work fine - I assume because they don't contain expressions or pass an argument from the main query. Any help you could offer would be great! Here is the main query: http://snipt.org/ufiS3 Here is the function in question: http://snipt.org/ufiQ1 Regards, Chris On 13/03/12 11:16 PM, Peter Stadler wrote: > Maybe you're passing a document-node() to your module? > Can you try with a double slash after your $doc, e.g. $doc//tei:teiHeader/tei:profileDesc/tei:particDesc/tei:person/tei:birth/text() > and/or make it explicit via > declare function bibl:dob($doc as document-node()) as element() {...} > > Anyhow, I think we would need to see the whole files to be able to say more ... > > All the best > Peter > > Am 13.03.2012 um 10:58 schrieb Christopher Thomson: > >> 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 >>>>>> >> ------------------------------------------------------------------------------ >> Keep Your Developer Skills Current with LearnDevNow! >> The most comprehensive online learning library for Microsoft developers >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, >> Metro Style Apps, more. Free future releases when you subscribe now! >> http://p.sf.net/sfu/learndevnow-d2d >> _______________________________________________ >> eXist-TEIXML mailing list >> eXi...@li... >> https://lists.sourceforge.net/lists/listinfo/exist-teixml |