Re: author elements in tei headers

From: Ashley M. Clark <as.clark_at_nyob>
Date: Mon, 9 Jan 2017 12:17:06 -0500
To: CODE4LIB_at_LISTS.CLIR.ORG
Hi Eric,

In XPath, each `/` says to go down the XML tree hierarchy once, and a 
double slash (`//`) says "I don't care how far down I have to go from my 
starting position, get me all descendants that match the next thing I 
specify". So you can use a slightly more explicit XPath to find what you 
need:

`//teiHeader//author` -> "Go to <teiHeader>, then get all its descendant 
<author>s"
`//text//author` -> "Go to <text>, then get all its descendant <author>s"

To get counts in pure XPath (you'll have to check if your parser can 
handle functions like this), you can use the count function:

`count(//teiHeader//author)` -> "Get a count of the results for 
`//teiHeader//author`"

Hope this helps!

Best,
Ashley

-- 

Ashley M. Clark
XML Applications Developer
Digital Scholarship Group
Northeastern University Libraries
as.clark_at_neu.edu <mailto:as.clark_at_neu.edu>
(617) 373-5983


On 1/9/17 11:55 AM, Eric Lease Morgan wrote:
> I have an XPath question, and more specifically, how can I determine the number of author elements found an a TEI header?
>
> I would like to create summary files similar to the files created by the late Sebastian Rantz and found on GitHub. [1] I can easily determine the number of author elements found in an entire TEI file with a Perl-esque XPath statement similar to this:
>
>    $parser->find( ā€œ//author" )->size
>
> But I’d like to know how to limit the finding of author elements to only the teiheader or text elements.
>
> [1] see, for example - https://github.com/textcreationpartnership/A00002
>
> —
> Eric Morgan
Received on Mon Jan 09 2017 - 12:17:18 EST