<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.tei-c.org/index.php?action=history&amp;feed=atom&amp;title=Talk%3ANotesToRefs.xsl</id>
	<title>Talk:NotesToRefs.xsl - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.tei-c.org/index.php?action=history&amp;feed=atom&amp;title=Talk%3ANotesToRefs.xsl"/>
	<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=Talk:NotesToRefs.xsl&amp;action=history"/>
	<updated>2026-04-22T06:18:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>https://wiki.tei-c.org/index.php?title=Talk:NotesToRefs.xsl&amp;diff=9186&amp;oldid=prev</id>
		<title>Syd: improved(?) version</title>
		<link rel="alternate" type="text/html" href="https://wiki.tei-c.org/index.php?title=Talk:NotesToRefs.xsl&amp;diff=9186&amp;oldid=prev"/>
		<updated>2011-04-09T12:39:46Z</updated>

		<summary type="html">&lt;p&gt;improved(?) version&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;For obscure reasons I was poking around this stylesheet, trying to figure out what it did. In doing so I started to re-write it a bit in my head, and then thought “why not re-write it for real?”.&lt;br /&gt;
&lt;br /&gt;
I '''think''' the following performs the same task. I also think it is easier to follow, and is more “XSLT-like” (i.e., declarative) in its structure, although others may disagree.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;xsl:stylesheet xmlns:xsl=&amp;quot;http://www.w3.org/1999/XSL/Transform&amp;quot; exclude-result-prefixes=&amp;quot;tei&amp;quot;&lt;br /&gt;
  xmlns:tei=&amp;quot;http://www.tei-c.org/ns/1.0&amp;quot; xmlns=&amp;quot;http://www.tei-c.org/ns/1.0&amp;quot; version=&amp;quot;1.0&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- possibly improved version of movingnotes.xsl, which I found at &lt;br /&gt;
    http://wiki.tei-c.org/index.php/NotesToRefs.xsl  — Syd Bauman, 2011-04-09 &lt;br /&gt;
    --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- just to make it easy to change the type= of our generated &amp;lt;ref&amp;gt; elements --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:variable name=&amp;quot;refType&amp;quot; select=&amp;quot;'nota'&amp;quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- identity transform --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;comment()|processing-instruction()|text()&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:copy/&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;*&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:copy&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:copy-of select=&amp;quot;@*&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:apply-templates select=&amp;quot;comment()|processing-instruction()|text()|*&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:copy&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- if &amp;lt;text&amp;gt; doesn't have a &amp;lt;back&amp;gt;, give it one ... --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;tei:text&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:copy&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:apply-templates select=&amp;quot;@*|node()&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:if test=&amp;quot;not( tei:back )&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;back&amp;gt;&lt;br /&gt;
          &amp;lt;!-- ... inserting our note &amp;lt;div&amp;gt; into it --&amp;gt;&lt;br /&gt;
          &amp;lt;xsl:call-template name=&amp;quot;make-note-div&amp;quot;/&amp;gt;&lt;br /&gt;
        &amp;lt;/back&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:if&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:copy&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- insert our note &amp;lt;div&amp;gt; at the end of source &amp;lt;back&amp;gt; --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;back&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:copy&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:apply-templates select=&amp;quot;@*|node()&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:call-template name=&amp;quot;make-note-div&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/xsl:copy&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;xsl:template name=&amp;quot;make-note-div&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div type=&amp;quot;notes&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;head xml:lang=&amp;quot;la&amp;quot;&amp;gt;Notae&amp;lt;/head&amp;gt;&lt;br /&gt;
      &amp;lt;pb n=&amp;quot;nts&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:apply-templates select=&amp;quot;//tei:note&amp;quot; mode=&amp;quot;moveback&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- When we come across a &amp;lt;note&amp;gt; in normal processing, put out a &amp;lt;ref&amp;gt; --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- instead. (We use &amp;lt;ref&amp;gt; instead of &amp;lt;ptr&amp;gt; as that's what PhiloLogic --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- calls for, even though &amp;lt;ptr&amp;gt; would be more appropriate.) --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;tei:note&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ref type=&amp;quot;{$refType}&amp;quot; target=&amp;quot;{concat('n',generate-id(.))}&amp;quot; xmlns=&amp;quot;http://www.tei-c.org/ns/1.0&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:attribute name=&amp;quot;xml:id&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;!-- see [1] --&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:value-of select=&amp;quot;concat('r',generate-id(.))&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:attribute&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:attribute name=&amp;quot;n&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:number/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:attribute&amp;gt;&lt;br /&gt;
    &amp;lt;/ref&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- When we call for a &amp;lt;note&amp;gt; in move-me-to-back mode, put out a --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- copy of the context node (the &amp;lt;note&amp;gt;) with the needed extra --&amp;gt;&lt;br /&gt;
  &amp;lt;!-- attributes. --&amp;gt;&lt;br /&gt;
  &amp;lt;xsl:template match=&amp;quot;tei:note&amp;quot; mode=&amp;quot;moveback&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;note place=&amp;quot;foot&amp;quot; target=&amp;quot;{concat('r',generate-id(.))}&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;!-- see [1] --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:attribute name=&amp;quot;xml:id&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;xsl:value-of select=&amp;quot;concat('n',generate-id(.))&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;/xsl:attribute&amp;gt;&lt;br /&gt;
      &amp;lt;!-- copy source attrs, but don't overwrite the ones we just --&amp;gt;&lt;br /&gt;
      &amp;lt;!-- created --&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:copy-of select=&amp;quot;@*[not(attribute::xml:id or attribute::target or attribute::place)]&amp;quot;/&amp;gt;&lt;br /&gt;
      &amp;lt;xsl:apply-templates select=&amp;quot;node()&amp;quot;/&amp;gt;&lt;br /&gt;
    &amp;lt;/note&amp;gt;&lt;br /&gt;
    &amp;lt;!-- add a carriage return, for tidiness --&amp;gt;&lt;br /&gt;
    &amp;lt;xsl:text&amp;gt;&amp;amp;#x0A;&amp;lt;/xsl:text&amp;gt;&lt;br /&gt;
  &amp;lt;/xsl:template&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;!-- [1]&lt;br /&gt;
    You can't create the xml:id= attribute using an attribute value template&lt;br /&gt;
    (at least not using xsltproc). I.e.,&lt;br /&gt;
       xml:id={concat('n',generate-id(.))}&lt;br /&gt;
    results in an error. I *think* this is because the result of evaluating an&lt;br /&gt;
    attribute value template is always a string, but an NCName is required. When&lt;br /&gt;
    the XSLT engine builds a tree fragment (as with &amp;lt;xsl:attribute&amp;gt;), it can&lt;br /&gt;
    build something more complex than a string, in this case an NCName.&lt;br /&gt;
  --&amp;gt;&lt;br /&gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Syd</name></author>
		
	</entry>
</feed>