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

XSLT_02 #720

Closed bobbyfunks closed 4 years ago

bobbyfunks commented 4 years ago

do we have to change the xml document at all? Its flagged from the start and nothing shows up in the output when I try to check it.

ebeshero commented 4 years ago

Hi @bobbyfunks No--the XML is okay--no changes necessary to it. It's got flags (okay--yes, I see, lots of red flags) from the Digital Mitford project schema, but the XML is well formed, so you can process it. (You can process anything that's well formed.)

DO make sure you copied in my xpath-default-namespace line from the assignment: it needs to read the TEI namespace. If that isn't it, show me your first template rule--I wonder if something is problematic there: you need that template to match on the document node to change TEI into HTML. And set a basic HTML root element inside the rule.

ebeshero commented 4 years ago

Let's check your XSLT root element, and the <xsl:output> element just in case something's wrong there. Here's what you should have:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
    xmlns="http://www.w3.org/1999/xhtml"
    xpath-default-namespace="http://www.tei-c.org/ns/1.0">

    <xsl:output method="xhtml" encoding="utf-8" doctype-system="about:legacy-compat"
        omit-xml-declaration="yes"/>

</xsl:stylesheet>
ebeshero commented 4 years ago

@bobbyfunks If all of that is okay, let's take a look at your template rules. The one template rule that's absolutely crucial for changing XML to HTML is the special one that matches on your document node. It would look like this:

<xsl:template match="/">
       <html>
                 <!--ebb: more code here for setting up an HTML document,  like the <head> and <body> elements...-->
                   <ul>
                     <xsl:apply-templates select="descendant::SOMETHING"/>
                 </ul>
      </html>

</xsl:template>

That xsl:apply-templates could be a problem if it's not written correctly. That must be a literal XPath down from the context of the template match, and it's reaching for elements in the source TEI document. Check that source TEI document and make sure you're selecting (and spelling correctly?) the elements you want to be processing next.

And you'll then need a new template rule to match on elements (anywhere on the tree) that will happen to be those very elements you selected...But even before you write that rule, you can test your first template rule just by running the XSLT. You'll probably get the default template rules to apply and get a dump of output text if everything's connected up properly...

ebeshero commented 4 years ago

...If it isn't connected up properly, check those menu entries in oXygen to be sure you've selected the source TEI file to process, and the XSLT file up there. (That's often a reason I don't see output when I try to run an XSLT...)

bobbyfunks commented 4 years ago

ok thanks. that helped