Difference between revisions of "Talk:MilestoneXSLT"

From TEIWiki
Jump to navigation Jump to search
(Script 2: suggestions for improvement: new section)
m (Script 2: suggestions for improvement: code optimisation)
 
Line 8: Line 8:
 
#Just a minor point, but I think the line <code><xsl:variable name="cur-p" select="generate-id(.)"/></code> is unnecessary, because this variable isn't used anywhere. I assume it's a relict from the XSLT 1.0 version.
 
#Just a minor point, but I think the line <code><xsl:variable name="cur-p" select="generate-id(.)"/></code> is unnecessary, because this variable isn't used anywhere. I assume it's a relict from the XSLT 1.0 version.
 
#The line <code><xsl:sequence select="current()/ancestor::p[1]/lb/@*"/></code> doesn't seem entirely correct; more precisely, it only works for the particular example input provided, but not when there are multiple lb elements, in which case only the attribute value of the last lb is applied to each lb element.
 
#The line <code><xsl:sequence select="current()/ancestor::p[1]/lb/@*"/></code> doesn't seem entirely correct; more precisely, it only works for the particular example input provided, but not when there are multiple lb elements, in which case only the attribute value of the last lb is applied to each lb element.
#Instead, in order to copy the attributes, I suggest to add <source lang="xml"><xsl:for-each select="@*"><xsl:copy-of select="."/></xsl:for-each></source> after each of the tags inserted in step2 (p, lb, del), e.g. <source lang="xml"><p xmlns="http://www.tei-c.org/ns/1.0"><xsl:for-each select="@*"><xsl:copy-of select="."/></xsl:for-each></source> etc. Note, however, that this might add unwanted default attributes to the output - see https://listserv.brown.edu/archives/cgi-bin/wa?A2=TEI-L;42710be0.1404 for solutions to this problem.
+
#Instead, in order to copy the attributes, I suggest to add <source lang="xml"><xsl:copy-of select="@*"/></source> after each of the tags inserted in step2 (p, lb, del), e.g. <source lang="xml"><p xmlns="http://www.tei-c.org/ns/1.0"><xsl:copy-of select="@*"/></source> etc. Note, however, that this might add unwanted default attributes to the output - see https://listserv.brown.edu/archives/cgi-bin/wa?A2=TEI-L;42710be0.1404 for solutions to this problem.
 
--[[User:Martin de la Iglesia|Martin de la Iglesia]] 12:23, 18 April 2018 (CEST)
 
--[[User:Martin de la Iglesia|Martin de la Iglesia]] 12:23, 18 April 2018 (CEST)

Latest revision as of 11:22, 19 April 2018

More comments, please

I found these pieces of code highly useful, but (despite having worked with XSLT before) it took me very long to understand how they actually work, i.e. what some of the expressions actually do. Maybe future readers would benefit from some comments added to the code. --Martin de la Iglesia 05:57, 6 August 2012 (EDT)

Script 2: suggestions for improvement

regarding the 2nd of the XSLT 2.0 stylesheets:

  1. Just a minor point, but I think the line <xsl:variable name="cur-p" select="generate-id(.)"/> is unnecessary, because this variable isn't used anywhere. I assume it's a relict from the XSLT 1.0 version.
  2. The line <xsl:sequence select="current()/ancestor::p[1]/lb/@*"/> doesn't seem entirely correct; more precisely, it only works for the particular example input provided, but not when there are multiple lb elements, in which case only the attribute value of the last lb is applied to each lb element.
  3. Instead, in order to copy the attributes, I suggest to add <source lang="xml"><xsl:copy-of select="@*"/></source> after each of the tags inserted in step2 (p, lb, del), e.g. <source lang="xml">

    <xsl:copy-of select="@*"/></source> etc. Note, however, that this might add unwanted default attributes to the output - see https://listserv.brown.edu/archives/cgi-bin/wa?A2=TEI-L;42710be0.1404 for solutions to this problem.

--Martin de la Iglesia 12:23, 18 April 2018 (CEST)