Problem with XML

admin

Administrator
Staff member
Hi all,I've only just begun using XML and have run into a problemn that I can'tfind a way around. Sorry in advance for the length of this post.I want to apply an XSL file to an XML file I have that will display the resultin HTML format (so far so good). The XSL file has to insert a pair of radio(option) buttons into the HTML to correspond with each element. The problemis that I want to name the option buttons using the 'name' attribute of theelement, and as the value of the 'name' attribute has spaces in it I wishto replace them with underscores. I've tried using the 'translate' function,ie:<input type="radio" value=http://forums.devx.com/archive/index.php/"0" checked="checked"><xsl:attribute name="name"><xsl:value-of select="translate('name',' ','_')"/></xsl:attribute></input>but get the error; "unknown method-->'"translate('name'<--'I've also tried writing a Javascript function:<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:msxsl="urn:schemas-microsoft-com:xslt"xmlns:user="http://www.itcg-advisor.co.uk" version="1.0"><msxsl:script language="javascript" implements-prefix="user"><![CDATA[function RemoveSpaces(sString){var newString=sString.match(" ","_");return newString;}]]></msxsl:script>and calling it using:<input type="radio" value=http://forums.devx.com/archive/index.php/"0" checked="checked"><xsl:attribute name="name"><xsl:value-of select="user:RemoveSpaces(name)"/></xsl:attribute></input>but the HTML when displayed in the browser simply prints out the above functionat the top of the web-page and does not seem to get as far as attemptingto alter the value of the'name' attribute.I realise that this is most probably an elementary error on my part, butif anyone out there could point out to me where I am going wrong in the abovecode I'd be grateful.Sorry about the size of this post, and thanks in advance,Don.
 
Back
Top