This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: How I can include javscript code ?


This has nothing to do with the script being in a CDATA section -- it's just
an effect of the HTML output method...

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Charles Knell
> Sent: Wednesday, July 10, 2002 4:18 PM
> To: xsl-list@lists.mulberrytech.com
> Subject: Re: [xsl] How I can include javscript code ?
>
>
> You can try this universe, Mike.
>
> This stylesheet:
> #######################
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="html" indent="yes" encoding="UTF-8" />
> <xsl:template match="/">
>   <html>
>     <head>
>       <script language="JavaScript">
>       <![CDATA[
>         function twiZone(Node){
>           if(Node >= 1){
>             alert("This one.");
>           }
>         }
>       ]]>
>       </script>
>     </head>
>     <body onload="twiZone(3)">
>
>     </body>
>   </html>
> </xsl:template>
> </xsl:stylesheet>
> #######################
> Produces this output:
> #######################
> <html>
> <head>
> <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
> <script language="JavaScript">
>
>         function twiZone(Node){
>           if(Node >= 1){
>             alert("This one.");
>           }
>         }
>
>       </script>
> </head>
> <body onload="twiZone(3)"></body>
> </html>
> #######################
> And if you don't want to type the <![CDATA[ ]]> tags in manually, you
> can use the cdata-section-elements attribute of the <xsl:output> element
> like this:
>
> <xsl:output cdata-section-elements="script">
> --
> Charles Knell
> cknell@onebox.com - email
>
>
> ---- Mike Brown <mike@skew.org> wrote:
> > Charles Knell wrote:
> > > There's no need to disable output escaping if you enclose your code
> > in
> > > <![CDATA[ ]]> tags.
> >
> > In what alternate universe?
> >
> >    - Mike
> >
> __________________________________________________________________
> __________
> >   mike j. brown                   |  xml/xslt: http://skew.org/xml/
> >   denver/boulder, colorado, usa   |  resume:
http://skew.org/~mike/resume/
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>
>

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]