This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes translate function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "translate function" Watch "translate function" New topic

translate function

Guruprasad Kateel

Joined: Jul 10, 2003
Posts: 16
I am trying to use translate function on a attribute value in the xml, but the following exception:
javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Expected ,, but found: @

<USER userId="offadmin" password="offadmin">

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl utput method="xml"/>
<xsl aram name="id"/>
<xsl aram name="pw"/>
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

<!-- Template for root rule -->
<xsl:template match="/">
<xsl:apply-templates select="translate(/USERDATA/USER@userId,$lowercase,$uppercase)" />
<xsl:copy-of select="USERDATA/USER[@userId=$id and @password=$pw]/*" />

I am seaching the xml based on the Userid(Case-insensitive search) and password.
Please let me know how do i achive this functionality and are there any alternatives to do the same job?
Thanks and Regards,
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
On this line:
<xsl:apply-templates select="translate(/USERDATA/USER@userId,$lowercase,$uppercase)" />
you forgot one forward-slash between "USER" and "@".

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Have you checked out Aspose?
subject: translate function
It's not a secret anymore!