ebeshero / DHClass-Hub

a repository to help introduce and orient students to the GitHub collaboration environment, and to support DH classes.
GNU Affero General Public License v3.0
27 stars 27 forks source link

Help with tokenize #645

Closed ghost closed 5 years ago

ghost commented 5 years ago

I'll upload what I have so far. How do I separate the years? It is coming out as all one long number.

SVG help

ebeshero commented 5 years ago

@SparkTheDragon Yikes--somehow you are retrieving EVERY date in every single collection in eXist-db. (I didn't realize you could do that!) Remember that you need to use your collection variable to isolate a specific collection and walk down the tree from there. When you define the $date variable as starting with //, that's evidently getting ALL the collections.

Also you're going to need a for loop to treat the dates one-by-one.

ghost commented 5 years ago

When I change //date to /date there is no output. hmmmm

ebeshero commented 5 years ago

@SparkTheDragon You've written XQuery before that begins with a collection()... Remember why you define that collection variable in the first place, so you refer to it? The solution here is NOT to start your expression with a forward slash at all.

ebeshero commented 5 years ago

@SparkTheDragon So, you defined a collection with:

declare variable $banksyColl := collection('/db/Assignments/banksyForSVG/');

You need to refer to that variable, $banksyColl when you are trying to find the dates in that collection...

ghost commented 5 years ago

I did try to refer to that variable but now I do not get any dates. I get a string of the same sentence over and over again.

ebeshero commented 5 years ago

@SparkTheDragon Did you save this in eXist-db? Let me try looking at it in your folder. Also, what's your preferred T-shirt size? (I'm about to phone the T-shirt people with our class order.)

ebeshero commented 5 years ago

@SparkTheDragon I saved the starter XQuery that we wrote together in class on Wednesday in our eXist-db, so how about picking that up and running with it? You could at least compare notes--that XQuery is successfully pulling from the Banksy collection. Find it in our eXist-db here: /db/2019_ClassExamples/banksyTimelineStarter.xql

ghost commented 5 years ago

So sorry I didn't get back to you about my size. I am a medium, but Im sure I can squeeze into whatever.

ghost commented 5 years ago

Also, yea it is saved in my dtd21 folder.

ebeshero commented 5 years ago

@SparkTheDragon I'm not seeing it there--though I can see your other XQuery exercises...Can you make sure you save it? (Make sure you're logged in to eXist when you do.)

ghost commented 5 years ago

hmmm alright

ghost commented 5 years ago

my plan is to integrate my loops into the file you uploaded

ebeshero commented 5 years ago

This is what I see in your directory:

Screenshot 2019-04-04 20 52 04
ebeshero commented 5 years ago

@SparkTheDragon You'll only need the one loop that we started in class (reflected in my file). You just need to loop through each year and find the <sourceDesc> elements in the Banksy collection that match up with that year. That's the tricky part. Once you've found those, you can return titles in each year, counts of titles per year, whether they're spray_paint or canvas, etc.

ghost commented 5 years ago

SVG2 is the one I was working on. And alright, I'll work on that loop.

ebeshero commented 5 years ago

@SparkTheDragon I just had a look at "SVG2" and left you a comment there. You had a for-loop set up like this:

for $date in $banksyColl

That won't work to retrieve dates, because the for-loop just breaks a sequence into parts. In this case $banksyColl is a sequence of document nodes (each of the whole XML documents in the Banksy collection), so your $date is just returning entire files, not dates.

To retrieve the dates, we set a global variable reaching into the $banksyColl//sourceDesc//date/@when/string(). We then used the tokenize function to retrieve just the year portion of the ISO-formatted yyyy-mm-dd dates by breaking on the hyphens (and that works even if there aren't any hyphens). We wrote all that code together in class on Wednesday, so you'll see it in my code saved in the database.