RE: [xsl] using javascript in xslt

Subject: RE: [xsl] using javascript in xslt
From: "Prasad Akella" <avlnprasad@xxxxxx>
Date: Thu, 10 Feb 2005 19:06:43 +0100
hello kay,

frankly yes i was expecting the script to be executed. i have used the script before in xslt writing it in head and using the 
 <![CDATA[             ]]>
tags and was able to execute them. this part of script i had seen elsewhere which was written inline and i also wanted to write some inline script like this but am not able to do so.
can you advise something in this regard.

with regards,
Prasad


xsl-list@xxxxxxxxxxxxxxxxxxxxxx schrieb am 10.02.05 18:25:14:
> 
> <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: [xsl] 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
> 


______________________________________________________________
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

Current Thread