[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Conditionally Sum an Attribute

Subject: Re: Conditionally Sum an Attribute
From: "Ronnie Royston" <rhroyston@xxxxxxxxx>
Date: Sun, 1 Jun 2008 16:39:52 -0500
 Re: Conditionally Sum an Attribute
Wow! Making a machine speak English is a large problem!!!  Putting
spaces, commas, and a period at the end of a sentence wasn't too bad.
Adding making items plural is a very large problem.  Think about it,
if the word ends with an "h" such as "switch" then it needs an "es" to
be plural.  Some words such as "chassis" and "deer" are both singular
and plural and don't require any "s" or "es".  I guess the easiest
thing is to put a child element under each items <name> called
<plural> and return it if it is preceeded by other than "1 ", but that
gets me back in to an area of complexity that is beyond my reach (for
now).  I'll compromise and remove "chassis" from my list of names.

Actually, an importable stylesheet for making words plural could
probably be made in a week (or year) or two?  Maybe I'll make that a
project - some re-usable XSLT code that I can contribute to the world.
(I hope I said that right).

"DataVox is offering Reuters project services at a fixed price for the
installation of 1007 Cisco phones, 1 Cisco router, 3 Cisco switches,
and 5 Cisco switch linecards."

...close enough for now.

<xsl:for-each select="$names">
<xsl:choose>
       <xsl:when test="position()=1">
		<xsl:choose>
			<xsl:when test="starts-with(current(),'1 ')">
				<xsl:value-of select="concat(' ', .)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="ends-with(current(),'h')">
						<xsl:value-of select="concat(' ', .,'es')"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="concat(' ', .,'s')"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
       </xsl:when>
       <xsl:when test="position()=last()">
		<xsl:choose>
			<xsl:when test="starts-with(current(),'1 ')">
				<xsl:value-of select="concat(', and ', ., '. ')"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="ends-with(current(),'h')">
						<xsl:value-of select="concat(', and ', .,'es','. ')"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="concat(', and ', .,'s','. ')"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
       </xsl:when>
       <xsl:otherwise>
		<xsl:choose>
			<xsl:when test="starts-with(current(),'1 ')">
				<xsl:value-of select="concat(', ', .)"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="ends-with(current(),'h')">
						<xsl:value-of select="concat(', ', .,'es')"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="concat(', ', .,'s')"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
       </xsl:otherwise>
</xsl:choose>
</xsl:for-each>

Fun stuff...

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.