Link to home
Start Free TrialLog in
Avatar of AussieSilver
AussieSilver

asked on

convert the lower case to upper case

Hi Guys,

If you have a look at the attached code... the xslt reads attributes "from" and  "to" from the source document. in the source document, they are in lower-case. I want them be written in the results document in an upper case. Please look at my code where I have tried but  it did not work where it gives me the following error:

******
  SXXP0003: Error reported by XML parser: Element type "xsl:value-of" must be followed by
  either attribute specifications, ">" or "/>".
Failed to compile stylesheet. 1 error detected.

<from><xsl:value-of select="translate("@from", $smallcase, $uppercase)"/></from>
            <to><xsl:value-of select="translate("@to", $smallcase, $uppercase)"/></to>

Open in new window

Avatar of AussieSilver
AussieSilver

ASKER

My be it is not clear but here is the full xslt code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xsl:key name="search" match="wordEntry" use="search"/>
    <xsl:key name="replace" match="wordEntry" use="concat(search, '-', replace)"/>
    <xsl:template match="wordlist">
        <Dictionary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:noNamespaceSchemaLocation="translation.xsd">
            <from><xsl:value-of select="translate("@from", $smallcase, $uppercase)"/></from>
            <to><xsl:value-of select="translate("@to", $smallcase, $uppercase)"/></to>
            <total>
                <xsl:value-of select="count(wordEntry[generate-id() = generate-id(key('search', search)[1])])"/>
            </total>
            <xsl:apply-templates select="wordEntry[generate-id() = generate-id(key('search', search)[1])]"/>
        </Dictionary>
    </xsl:template>
    <xsl:template match="wordEntry">
        
        <translation initial="{substring(search ,1,1)}">
            <xsl:variable name="this-search" select="search"></xsl:variable>
            <xsl:copy-of select="search"/>
            <counter>
                <xsl:value-of select="count(//wordEntry[generate-id() =  generate-id(key('replace', concat($this-search, '-', replace))[1])])"/>
            </counter>
            <xsl:for-each select="//wordEntry[generate-id() =  generate-id(key('replace', concat($this-search, '-', replace))[1])]">
                <xsl:copy-of select="replace"/>
            </xsl:for-each>
        </translation>
    </xsl:template>
</xsl:stylesheet>

Open in new window

Avatar of Gertone (Geert Bormans)
remove the double quotes from the attributes @from and @to
 <from><xsl:value-of select="translate(@from, $smallcase, $uppercase)"/></from>
            <to><xsl:value-of select="translate(@to, $smallcase, $uppercase)"/></to>
 
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i think its causing due to the imbalance in the double quotes,

Pls refer the snippet

Hope this helps
<from><xsl:value-of select="translate(@from, $smallcase, $uppercase)"/></from>
            <to><xsl:value-of select="translate(@to, $smallcase, $uppercase)"/></to>

Open in new window

YOU ARE THE BEST !!!!
Sorry shinug

I should have declared the $smallcase and $uppercase....
Note that:
- in XPath functions and expressions, you don't need to put quotes (or single quotes) around the XPath. It will be evaluated as a string, in this case you don't want the string "@from" in the translate(); you want the attribute from
- strings in double-quote delimited attribute values should be seperated by single -quotes, to keep the balance right
- the translate function is a work-around for uppercasing in this example, but you will need every character in the uppercase, explicitely mentuioned in a variable, which I added for you
GREAT... thanks very much Gertone... I wish i give you 1000000 points