Altova Mailing List Archives


RE: [xsl] Calling function with text parameter

From: "Michael Kay" <michael.h.kay@------------>
To:
Date: 10/31/2002 1:30:00 PM
There is no way within the XSLT 1.0 standard to force the serializer to
output apostrophe as ' rather than &apos;, but there might be a way in
your chosen product (which you don't name).

Do browsers really treat ' and &apos; 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&eacute;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(&apos;hello&apos;)">...
> 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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.