DigitalMitford / DM_processing

a repo for working on processing for the Digital Mitford project, including schemas, XSLT, XQuery, and other production and analysis efforts
http://digitalmitford.org
GNU Affero General Public License v3.0
8 stars 3 forks source link

counting letters--posting for reference #4

Closed ezimmer closed 8 years ago

ezimmer commented 9 years ago

Actually, this is just an excited post! (Will need to commit this, but I figured out the earlier question.) I think my real question now is, am I right to say we have 54 letters?

This is the query I used:

`(: This query counts the letters in the Mitford ‘letters’ folder. :)

xquery version "3.0"; declare default element namespace "http://www.tei-c.org/ns/1.0"; let $letters := collection('/db/letters') return count($letters)`

This returns 54.

(p.s., @mollyodonnell , this is actually huge fun, as odd as that sounds—I think you might like it whenever there’s time to talk about it.)

Also, resources:

@ebeshero ’s excellent tutorial: [http://www.pitt.edu/~ebb8/DHDS/explainXQuery.html] XQuery/XPath wikibook: [https://en.wikibooks.org/wiki/XQuery/XPath_examples] A further resource on collections specifically (may or may not always apply): [https://docs.marklogic.com/guide/search-dev/collections]

Great resource on how to do markdown (even if I’m getting some wrong here): [http://www.daringfireball.net/projects/markdown/syntax]

ebeshero commented 9 years ago

@ezimmer Great start! I'm not actually sure if it's 54 in that collection you queried (seems like there should be more). I'm on my way to class so I'm not logged in to eXist right now. More to the point, to make sure it's right, I'd add one path step down on your query. To count each file, I'd count one thing in each file (instead of the entire collection). To do that, can you add one step into the root element of each? Then do the count and see if it is the same.

Try adding a forward slash and an asterisk to the end of your $letters variable to take one step down. Or it could be a slash and TEI since that's the name of our root element in all our files.

Just a nudge before I can log in to eXist later today!

ezimmer commented 9 years ago

Thanks @ebeshero ! (Was wondering about the number being low, too.)

Will work further along those lines as soon as possible!

ezimmer commented 9 years ago

Yes, 54 with the '*' and 'TEI' variants:

xquery version "3.0"; declare default element namespace "http://www.tei-c.org/ns/1.0"; let $letters := collection('/db/letters') return count($letters/*)

xquery version "3.0"; declare default element namespace "http://www.tei-c.org/ns/1.0"; let $letters := collection('/db/letters') return count($letters/TEI)

Thanks for the nudge on counting, too!