obdurodon / dh_course

Digital Humanities course site
GNU General Public License v3.0
20 stars 6 forks source link

XSLT #4 Line Breaks Within Sonnets #460

Closed marionbriley closed 3 years ago

marionbriley commented 4 years ago

Hi! I hope everyone is well. I got a little bit overexcited with XSLT 4 and started working on it before fully reading over the assignment. As a result, I used the following code to account for line breaks within sonnets.

`

</xsl:template>`

However, when I looked back at the assignment, I saw that the recommended method of doing this was to wrap the entire body of each sonnet within <p> tags and then to add a <br/> at the end of each line. My solution appeared to do the same thing, from a glance at the XHTML output, but is somewhat messier or more complicated behind the scenes, because I basically created a new paragraph for each line. Is there a major and fundamental difference between these solutions or would both work? I recognize that if I were to go back and use XPath on these, I would have to use different searches within each solution. I think the issue I'm getting at here is that coding question of when is less more, and when is it okay to have a somewhat more elaborate solution than necessary. Thoughts?

dap167 commented 4 years ago

Personally, if it looks the same, then it's probably fine as a general thing. The major difference between these is how they might be displayed in different contexts. For example, one site might have a larger margin and border between <p> elements, so the actual output would be different.

As for if you should, it's probably more on the 'no' side. <p> elements have an established use meant to separate blocks of text, and it makes more sense to refer to the entire sonnet as a paragraph than every individual line.

Rober-Igtm commented 4 years ago

I had a similar issue as well. I agree with Danny, using the paragraph elements purely for text blocks will not only produce the correct margin sizes, but will make the code more easily navigable for yourself and anyone else who accesses it.

djbpitt commented 4 years ago

@marionbriley @dap167 @Rober-Igtm Thank you, Marion, for the question, and thank you to Danny and Rob for responding. Our hope in these chats is that students will interact with one another—among other things, that makes it more interesting for everyone, and answering someone else’s question is a terrific way to learn.

The responses are correct, as is Marion’s original observation: as long as the output is valid HTML (save it to disk by setting the “Output” file in \<oXygen/> and then running the transformation, after which you can open the saved output file in \<oXygen/> and validate it) and you can make it look like sonnets using CSS, outputting each line as a <p> is fine. For example, you can CSS to adjust the margins (see https://www.w3schools.com/css/css_margin.asp), so that there won’t be wide spaces between the lines. If you decide to use <p> elements for lines, I might wrap each group of 14 lines in a <div> or <section> and adjust the margins around those elements to get the amount of space you want between sonnets.

Anyone want to try drafting some CSS for this type of output?