[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: using javascript in xslt

Subject: RE: using javascript in xslt
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 Feb 2005 17:24:51 -0000
javascript in xslt
<script> is just a literal result element that will be generated in the
output file, it means nothing special to the XSLT processor.

Were you expecting the JavaScript code to be executed during the
transformation?

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Prasad Akella [mailto:avlnprasad@xxxxxx] 
> Sent: 10 February 2005 17:03
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  using javascript in xslt
> 
> hi 
> 
> I am working on my template to transform xforms to xhtml. 
> with regard to that I am trying to use javascript in between 
> xslt but its not recognising the stuff and throwing 
> everything onto the browser as plain text. i am attching my 
> piece of code advise on changes. 
> 
> This part of code is to transform my Switch/Case using Toggle 
> from a Select control:
> 
> <xsl:template match="xforms:switch">
>               <script type="text/javascript">                  
>                 function switch(selectId)
>                 {
>                   var w = 
> document.getElementById(selectId).selectedIndex;
>                   var name = 
> document.getElementById(selectId).options[w].value;
>                 <xsl:for-each select="xforms:case">
>                     <xsl:variable name="caseId" select="@id"/>
>                     document.getElementById(<xsl:value-of
>                         select="$quot"/><xsl:value-of 
> select="@id"/><xsl:value-of
>                             
> select="$quot"/>).style.visibility="hidden";
>                 </xsl:for-each>
>                   
> document.getElementById(name).style.visibility="visible";
>                  }
>             </script>
>             <xsl:for-each select="xforms:case">
>                 <xsl:variable name="caseId" select="@id"/>
>                 <xsl:variable name="disp">
>                     <xsl:choose>
>                         <xsl:when test="@selected 
> ='true()'">visible</xsl:when>
>                          <xsl:otherwise>hidden</xsl:otherwise>
>                     </xsl:choose>
>                 </xsl:variable>			
>                <xsl:if test="$disp='visible'">
>                 <div id="{$caseId}" style="LEFT:0px; 
> POSITION:relative; TOP:0px; VISIBILITY:{$disp}; Z-INDEX:0">
>                         <xsl:apply-templates/>
>                 </div>
>                </xsl:if>
>             </xsl:for-each>
>         </xsl:template>
> 
> 
> This is my code of Select1 control in xforms:
> 
>  <!-- Xforms : Select1 -->
>         <xsl:template match="xforms:select1">           
>              <xsl:variable name="name" as="xs:string" select="@ref"/>
>             <xsl:variable name="value" as="xs:string" 
> select="@xforms:value"/>
>             <xsl:variable name="jump">
>                 <xsl:choose>
>                     <xsl:when 
> test="xforms:item/xforms:toggle">true</xsl:when>
>                     <xsl:otherwise>false</xsl:otherwise>
>                </xsl:choose>              
>             </xsl:variable>
>             <xsl:value-of select="xforms:label[1]"></xsl:value-of>
>              <xhtml:select>
>                  <xsl:attribute name="name">
>                      <xsl:call-template name="tail">
>                          <xsl:with-param name="string" 
> select="$name"/>
>                      </xsl:call-template>
>                  </xsl:attribute>
>                  <xsl:attribute name="id">
>                      <xsl:call-template name="tail">
>                          <xsl:with-param name="string" 
> select="$name"/>
>                      </xsl:call-template>                     
>                  </xsl:attribute>
>                         <xsl:call-template 
> name="copy-other-attributes"/>
>                        <xsl:for-each select="xforms:item">
>                            <!-- Combo box -->
>                            <xhtml:option value="{xforms:value}">
>                                <xsl:call-template 
> name="copy-other-attributes"/>
>                                <xsl:if test="$value = 
> string(xforms:value)">
>                                    <xsl:attribute 
> name="selected" select="'selected'"/>
>                                </xsl:if>
>                                <xsl:value-of select="xforms:label "/>
>                            </xhtml:option>
>                        </xsl:for-each>
>                  <xsl:if test="$jump='true'">
>                      <xsl:attribute name="onchange" 
> select="switch({$name});"/>                 
>                  </xsl:if>
>               </xhtml:select>
>            </xsl:template>
> 
> with regards,
> Prasad
> 
> ______________________________________________________________
> Verschicken Sie romantische, coole und witzige Bilder per SMS!
> Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.