aspose file tools
The moose likes XML and Related Technologies and the fly likes translate function Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply 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]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: translate function
 
Similar Threads
Help on setPrarameter() fror transformer..
XSL to html conversion
How to avoid spawning new lines when processing?
problem with xsl which contains param tags
returning strings using call-template