This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "translate function" Watch "translate function" New topic
Author

translate function

Guruprasad Kateel
Greenhorn

Joined: Jul 10, 2003
Posts: 16
Hi,
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: @

My XML:
<USERDATA>
<USER userId="offadmin" password="offadmin">
<ERROR_CODE>0</ERROR_CODE>
</USER>
</USERDATA>

My XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 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)" />
<USERDATA>
<xsl:copy-of select="USERDATA/USER[@userId=$id and @password=$pw]/*" />
</USERDATA>
</xsl:template>
</xsl:stylesheet>


Purpose:
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,
Prasad.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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]
 
wood burning stoves
 
subject: translate function
 
Similar Threads
returning strings using call-template
problem with xsl which contains param tags
Help on setPrarameter() fror transformer..
XSL to html conversion
How to avoid spawning new lines when processing?