 |
 |
 |
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...
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |