[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: starts-with on more than one item
At 07:10 PM 5/30/2008, David wrote:
glad you got it working, just one comment, Even without being terribly tricky, one might refactor and extend as <xsl:choose> <xsl:when test="position() = 1"> <xsl:text> </xsl:text> <xsl:otherwise> <xsl:when test="position()=last()"> <xsl:if test="position() > 2"> <xsl:text>,</xsl:text> </xsl:if> <xsl:text> and </xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>, </xsl:text> </xsl:otherwise> </xsl:choose> <xsl:value-of select="."/> As David says, moving the position()=1 test accounts for the case of a set with one member. Adding a test inside the position()=last() clause accounts for the case of two members, which presumably shouldn't get a comma between them. The problem of transposing from singular to plural forms reliably in English requires either NLP or at least a lookup table with all your possible terms; it's usually best dealt with by writing around it. E.g., not "router, tranformers, and chassis" but "routers (1), transformers (4), and chassis (3)". It's not elegant, but it's clear enough and not obviously wrong either. Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|