[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Calling function with text parameter
Subject: RE: [xsl] Calling function with text parameter From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Thu, 31 Oct 2002 23:37:09 -0000 |
There is no way within the XSLT 1.0 standard to force the serializer to output apostrophe as ' rather than ', but there might be a way in your chosen product (which you don't name). Do browsers really treat ' and ' differently? I'm appalled. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Hélder Sousa > Sent: 31 October 2002 17:07 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: FW: [xsl] Calling function with text parameter > > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
FW: [xsl] Calling function with tex, Hélder Sousa | Thread | Re: [xsl] Calling function with tex, Mike Brown |
Re: [xsl] Reprocessing XHTML with X, Peter Flynn | Date | RE: [xsl] Re: variables in XSLT, Michael Kay |
Month |