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

AussieSilverAsked:
Who is Participating?
 
Geert BormansInformation ArchitectCommented:
you also seem to miss a declaration for $smallcase and $uppercase?
This will work
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:variable name="smallcase" select="'azertyuiopqsdfghjklmwxcvbn'"></xsl:variable>
    <xsl:variable name="uppercase" select="'AZERTYUIOPQSDFGHJKLMWXCVBN'"></xsl:variable>
    <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

0
 
AussieSilverAuthor Commented:
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

0
 
Geert BormansInformation ArchitectCommented:
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>
 
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Shinesh PremrajanEngineering ManagerCommented:
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

0
 
AussieSilverAuthor Commented:
YOU ARE THE BEST !!!!
0
 
AussieSilverAuthor Commented:
Sorry shinug

I should have declared the $smallcase and $uppercase....
0
 
Geert BormansInformation ArchitectCommented:
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
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
 
AussieSilverAuthor Commented:
GREAT... thanks very much Gertone... I wish i give you 1000000 points
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.