Dear all,
I have a series of files, some of which I need to tokenize, some of which not.
this is an example of both types
Code:
<div>
1
text 〈: in latere intuentibus sinistro〉 text 〈: in latere intuentibus dextro〉 text
</div>
2
<div>
text 〈: in latere intuentibus sinistro〉 text
</div>
3
<div>
text
</div>
the code I have done in my understanding should first look for the separating string 〈:***whichever***〉, but only use it to tokenize when it is there. if that is not present, just apply other templates.
Code:
<xsl:variable name="sections">
<xsl:analyze-string select="." regex="(〈):(in latere intuentibus sinistro|in latere intuentibus dextro|in epystilio|in ipsa aedicula|in una linea|in parte aversa|in fgr.\s\w*\s*|in columna\s\w*\s*)(〉)">
<xsl:matching-substring>
<xsl:sequence select="."/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:template name="div[@type='edition']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<head>Text</head>
<xsl:choose>
<xsl:when test="contains(., $sections)">
<xsl:for-each select="tokenize(., $sections)">
<div n="{position()}" type="textpart">
<ab>
...
</ab>
</div>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<ab>
...
</ab>
</xsl:otherwise>
</xsl:choose>
What happens is that with example 1 it returns the string, in example 2 actually performs the tokenize() and do the rest of the work nicely, in example 3 I get an Error (rightly) saying that tokenize is a zero length string... I understand why this second error comes, as the string is not there. I do not understand why it got to the point of evaluating that piece of xsl.
Thanks for any help.