|
next
|
Subject: tokenize a string with \r Author: Dana Pearson Date: 25 Sep 2012 08:16 PM
|
Hoping someone might enlighten me about the use of tokenizing a string based on a carriage return. I'm using SS Enterprise Edition 2010.
I've used the tokenize function frequently but never on carriage return. My requirement here is to split a dc:alternative title string (see below). The string before the first \r will go the subfield/@code='a', the remainder of the content will go into @code='b'.
There are relatively few of instances of such title strings but when they occur, the string must be split. I tried substring before and after functions first but without the result I wanted although I had no idea whether it would split on the first or any \r. It did nothing.
But using the tokenize function has the same result.
I'm using \r because that is the character separating the last character on a line; the next character is the first on the following line. I've tried using �D; as well although they are the same.
Finally, in another content analysis stylesheet, I tried the following for which I received the error message:
"At least one xsl:matching-substring or xsl:non-matching-substring element must be present."
This is what I suspected about the variable construction but received no such error messages; that is, the test for
contains(.[@rdf:parseType], '\r+')">
has no effect at all.
Am I wrong that \r is the character to split this string?
my variable:
<xsl:for-each select="dc:alternative">
<xsl:variable name="t1">
<xsl:if test="contains(.[@rdf:parseType], '\r+')">
<xsl:value-of select="tokenize(.[@rdf:parseType], '\r+')"/>
</xsl:if>
</xsl:variable>
analyze string variable:
<xsl:template match="dc:alternative">
<xsl:variable name="t1">
<xsl:if test="contains(.[@rdf:parseType], '\r+')">
<xsl:analyze-string
regex="\r+"
select=".[@rdf:parseType]"/>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:if>
</xsl:variable>
<title><xsl:value-of select="$t1"/></title>
</xsl:template>
First example of most common source element content; second and third, the target of my problem.
<dc:alternative rdf:parseType="Literal">Jin Shi Yuan</dc:alternative>
<dc:alternative rdf:parseType="Literal">Máguas Amorosas de Elmano
Idílio Por Bocage</dc:alternative>
<dc:alternative rdf:parseType="Literal">Galateia
Écloga
Primeira e Segunda Parte</dc:alternative>
thanks,
Dana Pearson
|
|
|