Subject: FW: [xsl] Calling function with text parameter From: Hélder Sousa <hsousa@xxxxxx> Date: Thu, 31 Oct 2002 17:06:35 -0000 |
Hi ppl. I have a problem with my xsl... in the "this line" comment, i'm trying to set the value of "onClick" attribute, that is a javascript function with a text parameter, but in my html page it appears without the apostrophes ...<tr align="center" onClick="alert('hello')">... This isn't valid for javascript. The correct result must be ...<tr align="center" onClick="alert('hello')">... in my servlet, i'm using the next method to make the parse import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.DocumentResult; import org.dom4j.io.DocumentSource; import org.dom4j.io.SAXReader; public String getHTML(String xslfile) { try{ TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer( new StreamSource( xslfile ) ); DocumentSource source = new DocumentSource( document ); DocumentResult result = new DocumentResult(); transformer.transform( source, result ); // return the transformed document Document transformedDoc = result.getDocument(); String html = transformedDoc.asXML(); return html; } catch (TransformerException e){ return "<html><body><h1>Error</h1>" + e.getMessage() + "</body></html>"; } } Here is the xml and xls people.xml <?xml version="1.0" encoding="UTF-8"?> <people> <woman name="ana"> <woman name="joana"> <woman name="rute"> </people> people.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xslt"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:for-each select=".//people"> <xsl:element name="table"> <xsl:attribute name="width">95%</xsl:attribute> <xsl:attribute name="cellspacing">0</xsl:attribute> <xsl:attribute name="class">tableBorder</xsl:attribute> <xsl:for-each select="woman"> <xsl:element name="tr"> <xsl:attribute name="align">center</xsl:attribute> <!--this line--> <xsl:attribute name="onClick">alert('hello');</xsl:attribute> <xsl:element name="td"> <xsl:value-of select="@name"/> </xsl:element> </xsl:element> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:template> </xsl:transform> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Problem With Different Co, Schwartz, Rechell R, | Thread | RE: [xsl] Calling function with tex, Michael Kay |
RE: [xsl] Problem With Different Co, Adam Griffin | Date | RE: [xsl] String Manipulation - Dis, Michael Kay |
Month |