Hi Peter,

Yes, this should return both a tei:placeName and a tei:persName. It does so in BaseX.

Jens

xquery version "1.0";

declare namespace tei="http://www.tei-c.org/ns/1.0";

let $input :=
<TEI xmlns="http://www.tei-c.org/ns/1.0">
    <teiHeader>
        <fileDesc>
            <titleStmt>
                <title>Title</title>
            </titleStmt>
            <publicationStmt>
                <p>Publication Information</p>
            </publicationStmt>
            <sourceDesc>
                <p>Information about the source</p>
            </sourceDesc>
        </fileDesc>
    </teiHeader>
    <text>
        <body>
            <div xml:id="d1e263" type="prose">
                <head>THE ENCHANTED CASTLE.</head>
                <p>There are warm days in <placeName corresp="london">London</placeName> when even a
                    window-box fails to charm, and one longs for the more open spaces of the
                    country. </p>
            </div>
            <div xml:id="d1e1806" type="review">
                <head rend="it">RUS IN URBE.</head>
                <p>"Sellinger's Bound," danced to an air that lulled <title>Titania</title> to sleep
                    all through the winter at the Savoy, was the most popular, with its ring of a
                    dozen dancers, hands joined, running together into the centre of their circle,
                    as if to honour some imaginary deity—possibly <persName corresp="sharp">Mr.
                            <name rend="sc">Cecil Sharp</name></persName>, director of the Society,
                    who has collected and revived the airs to which they dance.</p>
            </div>
        </body>
    </text>
</TEI>

let $corresp := ('sharp', 'london') 
return
$input//(tei:placeName, tei:persName)[@corresp=$corresp]

On Dec 21, 2012, at 5:49 PM, Peter Watson <peter.watson@kellogg.ox.ac.uk> wrote:

Yes, I confirm that I could not get the alternatives to work in the XPath either.  Peter

On 21/12/2012 15:54, Jens Østergaard Petersen wrote:

On Dec 21, 2012, at 2:20 PM, Adam Retter <adam@exist-db.org> wrote:


Please excuse if I'm misunderstanding what you are trying to do. I assume you want to search both, persName and placeName, if both parameters are set? In this case you need to combine the two selections, e.g. with a union:

let $name-predicate := local:get-name-predicate(request:get-parameter('people',''))
let $place-predicate := local:get-name-predicate(request:get-parameter('place',''))


return
    (if($name-predicate) then (collection('/db/punch/data')//tei:persName[@corresp=$name-predicate]) else ())
union
    (if($place-predicate) then (collection('/db/punch/data')//tei:placeName[@corresp=$place-predicate]) else ())

Wolfgang


I think you could also avoid the union altogether. Wolfgang, would this be more efficient? 

let $corresp := (local:get-name-predicate(request:get-parameter('people','')),  local:get-name-predicate(request:get-parameter('place,''))) return
   collection('/db/punch/data')//tei:persName[@corresp=$corresp])

Thats the beauty of a language without null's where an empty sequence is a perfectly valid 'thing' to operate upon :-p

Well, then a sequence has to be introduced in the XPath,

collection('/db/punch/data')//(tei:persName, tei:placeName)[@corresp=$corresp]

Strangely, eXist does not handle this correctly, ignoring all but the first item in the sequence ….

Jens



--
Adam Retter

eXist Developer
{ United Kingdom }
adam@exist-db.org
irc://irc.freenode.net/existdb
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d_______________________________________________
eXist-TEIXML mailing list
eXist-TEIXML@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/exist-teixml



------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d


_______________________________________________
eXist-TEIXML mailing list
eXist-TEIXML@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/exist-teixml

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d_______________________________________________
eXist-TEIXML mailing list
eXist-TEIXML@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/exist-teixml