| 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
|
|
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]
|
 |
 |
|
|
subject: translate function
|
|
|