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

Exercise 5 (Help) #54

Closed CodyKarch closed 8 years ago

CodyKarch commented 8 years ago

I was wondering how I pick out the individual poems. I was trying to use this, but I know the poem part is wrong. <xsl:apply-templates select="$dickinsonColl//poem"/> </body> And I also was wondering how to test it, should I have every poem open as an XML and test it with my XSLT or what?

CodyKarch commented 8 years ago

I take back the "poem" part. I realized it what I was looking for.

CodyKarch commented 8 years ago

I take it back, I'm very lost..

nlottig94 commented 8 years ago

You're right, your problem is the //poem part. There aren't any <poem> elements, are there?

CodyKarch commented 8 years ago

No, but I'm confused at what I'm looking for. What singles out ever individual poem?

nlottig94 commented 8 years ago

Well everything we need rests in what element of the poem? We don't need every single poem because the XSLT is looking over the whole collection, so all of the poems are formatted the same way in the XMLs.

nlottig94 commented 8 years ago

As long as we look at one of the poems, the XSLT will apply to all of the poems.

CodyKarch commented 8 years ago

Well, all the information we need is in the body.. so I was thinking <xsl:apply-templates select="$dickinsonColl//body"/>

nlottig94 commented 8 years ago

Exactly!

CodyKarch commented 8 years ago

And now I need a template rule with that, right?

nlottig94 commented 8 years ago

Yes. Have you done your @mode yet?

CodyKarch commented 8 years ago

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xpath-default-namespace="http://www.tei-c.org/ns/1.0" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math" xmlns="http://www.w3.org/1999/xhtml" version="3.0">

<xsl:output method="xhtml" encoding="utf-8" doctype-system="about:legacy-compat"
    omit-xml-declaration="yes"/>
<xsl:variable name="dickinsonColl" select="collection('Dickinson')"/>
<xsl:template match="/">
    <html>
        <body>
            <h1 align="center">Emily Dickinson’s Fascicle 16</h1>
            <h2>Table of Contents</h2>
            <ul>
                <xsl:apply-templates select="$dickinsonColl//body" mode="toc">
                    <xsl:sort order="descending"/>
                </xsl:apply-templates>                         
            </ul>
            <hr></hr>
            <div id="main">
                <xsl:apply-templates select="$dickinsonColl//body"/>

            </div>
        </body>
    </html>
</xsl:template>
<xsl:template match="$dickinsonColl//body" mode="toc">
    <li>
        <a href="body"> 
            <xsl:apply-templates select="//body//title"/>
            <xsl:apply-templates select="//lg[1]/line[1]"/>
        </a> 
    </li>
</xsl:template>

/xsl:stylesheet

CodyKarch commented 8 years ago

This is what I have....

nlottig94 commented 8 years ago

You're right as far as I can see so far!

CodyKarch commented 8 years ago

The strange thing is that with all of that, NONE of it (except the H1 and H2) will show up when I test it

nlottig94 commented 8 years ago

I actually just noticed that you don't need to link within the <li> element. And don't you want to number the poems?

CodyKarch commented 8 years ago

Oh.. Okay.. I'll check that out.. and it said that this line can't find a file (this does not exist) `

nlottig94 commented 8 years ago

Is your XSLT saved in the same space as your collection of Dickinson poems?

CodyKarch commented 8 years ago

ohhh... It was, but I moved it, that matters?

nlottig94 commented 8 years ago

Yeah that matters.

nlottig94 commented 8 years ago

Did it do anything since you moved it?

CodyKarch commented 8 years ago

Nope. I placed my XSLT into the folder with my files, and tested it, and nothing changed.

nlottig94 commented 8 years ago

It doesn't have to be in the folder. For example, if your Dickinson folder is sitting on your desktop, then your XSLT has to be sitting on your desktop as well.

CodyKarch commented 8 years ago

I tried that... I placed my folder of Dickinson files on my desktop, and I placed my xslt on my desktop and tested it, but still the same...

nlottig94 commented 8 years ago

I copy and pasted your XSLT into my oxygen and I'm coming up with something.

CodyKarch commented 8 years ago

Did the whole thing work for you???

nlottig94 commented 8 years ago

Yes, except the poem titles aren't in order. I think its because of your <xsl:sort> element.

CodyKarch commented 8 years ago

See... I can't get the entire thing... I literally can only get the H1 and H2 parts of my HTML

nlottig94 commented 8 years ago

image

This is what it came up with on mine.

CodyKarch commented 8 years ago

In that section, I get: `<!DOCTYPE html SYSTEM "about:legacy-compat">

Emily Dickinson’s Fascicle 16

Table of Contents

nlottig94 commented 8 years ago

Hmmm.... @RJP43 any suggestions??

CodyKarch commented 8 years ago

I think there is a problem with my variable, but I can't pick what out...

RJP43 commented 8 years ago

Does assignment 5 even ask about sorting or using links? Make sure you are doing [Assignment 5]() and not assignment 6. In class I explained (in detail with what I wrote on the board) how the two parts of your variable were a name you choose for the collection and then the file path to the collection from where your xslt sits. I suggested to keep them in the same place so that you could use the same path I had shown in class.

Also, it looks to me like in your @match (not the first one on the document node obviously but on your second one) you are asking for more than what is necessary. Consider this: your first two initial @selects in your first match (inside of your html setup) are saying anything XSLT grabs will be from the body elements of the files from the collection; therefore, when you make a @match from that point on you can just match on any and all <body> elements and you don't need to repeat that you are going into the collection because XSLT already knows this from that first match's @select. So you could just say match="body". Then in your @select inside of that match on <body> elements you can simplify and say go from here (using the dot .) and go down to the title element (using the appropriate amount of slashes / in consideration of where the <title> elements sit in relation to <body>) and output all of those. You would do similarly for the first lines.

RJP43 commented 8 years ago

Feel free to refer back to our in-class example

RJP43 commented 8 years ago

Also @CodyKarch it looks like you are selecting elements that don't appear in the source XML files ... I suggest you take a closer look at the elements that you are trying to grab and reconsider how you are going about completing the assignment. Here is a snippet of the Dickinson XML: `

Poem 1 (J 327: 1862/1891)
     <lg>
        <l>Before I got my eye put out—</l>
        <l>I liked as well to see</l>
        <l>As other Creatures, that have Eyes—</l>
        <l>And know no other way—</l>
     </lg>`

versus the sonnets XML I used in-class: `

From fairest creatures we desire increase, That thereby beauty's rose might never die, But as the riper should by time decease, His tender heir might bear his memory:` I have suspicion you may also be looking and possibly grabbing from the wrong in-class example. Refer to my last comment for the right example because the [sonnets2.xsl](https://github.com/ebeshero/DHClass-Hub/blob/master/Class-Examples/XSLT/ExamplesFrom10-26_10-28_10-30/sonnets2.xsl) is more along the lines of what we will be covering today in class using xsl:sort and making AVT links. This worries me because I posted those examples as a reference for you guys in hopes that you can refer back to the example **IF** you get caught up in **trying to work out the XSLT on your own** for the assignment. The in-class examples are never exactly like the homework so obviously element names and several similar things (like hierarchy) cannot be replicated simply by copying from the example... the point is that you consciously work through the assignment on your own and then if you get stuck use the example to see where you are getting errors. Hopefully this helps.
RJP43 commented 8 years ago

Also thank you @nlottig94 for jumping on this issue ... I was engulfed in other homework and hadn't even noticed the GitHub pings until obviously much later.

ebeshero commented 8 years ago

@CodyKarch @RJP43 Good morning from Lyon, France! Cody, I just ran your XSLT, after saving it in a directory sitting immediately above the Dickinson collection of files. I'm getting output, just as @nlottig94 did. Since two of us are getting output, I think the problem really must be where you are positioning your XSLT in relation to the collection directory--and I'm trying to anticipate what could be going wrong for you: Could it be one of the following?

  • Have you renamed the Dickinson collection folder? (If so, you need to point in your XSLT folder to wherever that collection folder is. OR just make sure your collection folder is named Dickinson.)
  • Is your XSLT file saved in the PARENT directory, sitting just above the Dickinson folder? When you look at where you've saved your XSLT file, does it look something like this?

CodyXSLTEX5.xsl [Dickinson] your Dickinson folder sitting here

Since your XSLT really and truly is working for me all the way out here in France, I can only think the problem has to be where you're positioning your file and the Dickinson directory.

  • I wonder if you've got this directory structure set up--could you be saving your XSLT in two different places by accident--and when you're running your XSLT you're actually running it from the wrong file location? Try closing all your open files in oXygen and reopening your XSLT from the right directory!

Hope this helps! Dr. B

RJP43 commented 8 years ago

Even further clarification: with the path we showed in class and how you have it in what you have sampled here fore us the XSLT sits beside not inside the folder that contains the collection files.

RJP43 commented 8 years ago

screenshot_1

RJP43 commented 8 years ago

or if inside of a folder instead of on your desktop it might look similar to how we have things saved here on GitHub for the class example ---- found here

RJP43 commented 8 years ago

screenshot_1

spadafour commented 8 years ago

I'm having a very similar issue to Cody; I can't seem to get anything at all to output besides the html frame that I created. I'm getting this message: FODC0002: The file or directory file:/Users/spada4/Documents/School/Pitt/Fall%202015/Digit%20Humanities/5.%20XSLT/Dickinson does not exist

That is in reference to this: <xsl:apply-templates select="$dickinsonColl//body"/>

This is a screenshot of my file locations, just to show that: screen shot 2015-10-28 at 9 03 11 am

I'm unsure how to continue if I can't check what I'm attempting to output.

nlottig94 commented 8 years ago

Do you have your collection() value as "Dickinson"? Like this? <xsl:variable name="dickinsonColl" select="collection('Dickinson')"/>

spadafour commented 8 years ago

Yep: <xsl:variable name="dickinsonColl" select="collection('Dickinson')"/>

I moved the Dickinson collection into the parent folder (where the error message seemed to be pointing), and I found this error: SXXP0003: org.xml.sax.SAXParseException; systemId: file:/Users/spada4/Documents/School/Pitt/Fall%202015/Digit%20Humanities/5.%20XSLT/Dickinson/.DS_Store; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.

nlottig94 commented 8 years ago

Did you try just putting them both on your desktop?

spadafour commented 8 years ago

Okay, just tried that. Still a fatal error, same one as my last comment.

nlottig94 commented 8 years ago

Hmmm...do you have everything else finished for the assignment? I could compare it to mine before class and we could see what's up with it. You available before class?

spadafour commented 8 years ago

I can meet up before class, but I don't have the assignment done, I've spent all my time just trying to figure out how to produce something at all from the Dickinson files.

RJP43 commented 8 years ago

Retry saving the Dickinson collection to your desktop by syncing and copying the folder from the GitHub desktop client

RJP43 commented 8 years ago

I can wait to post solutions and will keep the upload link active and we can have a look at it before class. My first class ends at 10:20 so I will get to the classroom ASAP

RJP43 commented 8 years ago

Thasks @nlottig94