[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Trying to find following sibling that ends in pun
Michael here is the function but it has worked perfectly(or as perfectly
as can be) in other instances.
<xsl:function name="f:f_StringEndsWith" as="xs:string"> <!-- p_String to test --> <xsl:param name="p_String" /> <!-- get the last character --> <xsl:variable name="l_LastCharacter" select="substring($p_String, string-length($p_String), 1)" /> <!-- get the last two characters --> <xsl:variable name="l_LastTwoCharacter" select="substring($p_String, string-length($p_String) - 1, 2)" /> <!-- . : ! ? --> <xsl:variable name="l_LastCharacterIs" select="if (matches($l_LastCharacter, '[.]|[:]|[!]|[?]')) then 'punct' else 'noPunct'" /> <!-- ." !" ?" .) !) ?) --> <!--xsl:variable name="l_LastTwoCharacterAre" select="if (matches($l_LastTwoCharacter, '[."]|[!"]|[?"]|[.)]|[!)]|[?)]')) then 'punct' else 'noPunct'" /--> <!-- the above failed in a couple of instances and so the var and choose below works. it is in longhand for ease of maintaining --> <!-- ." !" ?" .) !) ?) --> <xsl:variable name="l_LastTwoCharacterAre"> <xsl:choose> <xsl:when test="$l_LastTwoCharacter = '."'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:when test="$l_LastTwoCharacter = '!"'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:when test="$l_LastTwoCharacter = '?"'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:when test="$l_LastTwoCharacter = '.)'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:when test="$l_LastTwoCharacter = '!)'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:when test="$l_LastTwoCharacter = '?)'"><xsl:value-of select="'punct'" /></xsl:when> <xsl:otherwise><xsl:value-of select="'noPunct'" /></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:choose> <xsl:when test="($l_LastCharacterIs = 'punct') or ($l_LastTwoCharacterAre = 'punct')"><xsl:value-of select="'punct'" /></xsl:when> <xsl:otherwise><xsl:value-of select="'noPunct'" /></xsl:otherwise> </xsl:choose> </xsl:function> I'll add a test for an empty string and will test if any data is present. Thanks Mario Michael Kay wrote: You haven't shown the function
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|