[xsl] RE:creating canonRef from flat

Subject: [xsl] RE:creating canonRef from flat
From: Jim_Albright@xxxxxxxxxxxx
Date: Sat, 20 Sep 2003 09:27:33 -0400
Thank you to David, Jim, and Michael
Here is working code
I am looking forward to adding select on an attribute. That makes the code 
much nicer.
The lookup table is great! Really is elegant.
Thanks again for all your help on the list.

<xsl:template match="r">
  <xsl:element name="parallelPassage">
    <xsl:analyze-string select="." regex="[^;]+">
      <xsl:matching-substring>
        <xsl:element name="canonRef">
          <xsl:analyze-string select="." 
regex="([^\s]+)\s([0-9]+)\.([0-9]+)\-([0-9]+)">
            <xsl:matching-substring>
              <xsl:attribute name="book">
                <xsl:value-of select="my:abbrev(regex-group(1))"/>
              </xsl:attribute>
              <xsl:attribute name="chapter">
                <xsl:value-of select="regex-group(2)"/>
              </xsl:attribute>
              <xsl:attribute name="verse">
                <xsl:value-of select="regex-group(3)"/>
              </xsl:attribute>
              <xsl:if test="regex-group(4)">
                <xsl:attribute name="verseEnd">
                  <xsl:value-of select="regex-group(4)"/>
                </xsl:attribute>
              </xsl:if>
            </xsl:matching-substring>
          </xsl:analyze-string>
        </xsl:element>
      </xsl:matching-substring>
    </xsl:analyze-string>
  </xsl:element>
</xsl:template>


<xsl:function name="my:abbrev">
  <xsl:param name="long-name"/>
  <xsl:variable name="table">
    <book long="Mateus" short="MAT"/>
    <book long="Marcos" short="MRK"/>
    <book long="Lucas" short="LUK"/>
    <book long="João" short="JHN"/>
  </xsl:variable>
  <xsl:sequence select="$table/book[@long=$long-name]/@short"/>
</xsl:function>


Jim Albright
704 843-0582
Wycliffe Bible Translators



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread