Re: [xsl] creating canonRef from flat

Subject: Re: [xsl] creating canonRef from flat
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 19 Sep 2003 22:52:50 +0100
Oh sorry I didn't notice that you were changing the format of the book
names, Mike's posted a solution already but for the record here's my
version again with the lookup table for changing names stolen from
Mike's.

Both of our solutions assumed that the long book names don't include
spaces, as we're splitting on spaces to look for the chapter numbers.
If that isn't the case the regexp will need tweaking a bit.

The hardest part of getting this working was spelling regexp without a p
and analyse without an s...

David

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="2.0">


<xsl:output indent="yes"/>

<xsl:variable name="books">
    <book long="Mateus" short="MAT"/>
    <book long="Lucas" short="LUK"/>
</xsl:variable>

<xsl:template match="r">
<parallelPassage>
<xsl:analyze-string  regex="[^;]+" select=".">
<xsl:matching-substring>
<xsl:analyze-string  regex="([A-Za-z]+)
*([0-9]+)\.([0-9]+)-([0-9]+)(.*$)" select=".">
<xsl:matching-substring>
<canonRef
Book="{$books/book[@long=regex-group(1)]/@short}"
chapter="{regex-group(2)}"
verse="{regex-group(3)}"
verseend="{regex-group(4)}"
/>
</xsl:matching-substring>
</xsl:analyze-string >
</xsl:matching-substring>
</xsl:analyze-string>
</parallelPassage>
</xsl:template>

</xsl:stylesheet>

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


Current Thread