On 26/08/2010 10:30, pankaj(_dot_)c(_at_)thomsondigital(_dot_)com wrote:
Hello all,
I just did the following test for one of the requirement in my stylesheet.
Though I am able to get the correct result but somehow I am not convinced
with the approach. There must be better/correct way of doing this.
source
=====
<label>#x2022</label><!-- HEXADECIMAL FOR BULLET ACTUALLY WITH
'AMPERSAND' AND ; ADDED TO IT -->
Test
====
<xsl:template match="label">
<xsl:copy>
<xsl:choose>
<xsl:when test=".='.'"><!-- ='.' IS LITERAL BULLET SYMBOL -->
If you don't want to use a bullet character you can use the numeric
reference, just as your source has done and test
. = '& # x 2 0 2 2 ;'
It's not really clear if that is what you are asking?
<!-- Do Something here -->
</xsl:when>
<xsl:when test=".!='.'"><!-- ='.' IS LITERAL BULLET SYMBOL -->
xsl:otherwise is of course more efficient than testing the negation
which is repeating the test done in the previous clause.
<!-- Do Something different here -->
</xsl:when>
</xsl:choose>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:when test=".= 'BULLET SIGN'"> doesn't seems to be nice to me. Is
there any better way to test hexadecimal values.
Apart from this is there a way of testing whether string is a digit or
character<label>1.</label> <label>a.</label>.
you can test if number(.)=number(.) If the string represents a number,
this is true, if it is a non number it is the test NaN = NaN which is
false.
Not tested:
I believe<xsl:when test=".='BULLET SIGN'"> will check for the literal
string instead of something like [A-Za-z0-9]. I am using XSLT 1.0.
Any thoughts will be appreciated.
TIA,
Pankaj
david
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--