Go Back   CodingForums.com > :: Client side development > XML

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2003, 10:20 PM   PM User | #1
Evlich
New Coder

 
Join Date: Jun 2002
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Evlich is an unknown quantity at this point
JS function call as XSL output?

Hello, I am working with an xsl file that I want to create a scroller, but the scroller is not completely self contained and it needs to call a javascript function called addScroller() in order to start working. Is there a way that I can do this? This is what I have written right now:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="scroller">
 <div id="spacer{generate-id()}" style="height: {@height}px; width: {@width}px;"></div>
 <div id="clipper{generate-id()}" style="position: absolute; top: 0px; width: 0px; height: 0px; width: 0px;">
  <div id="scroller{generate-id()}" style="position: absolute; top: 0px; width: 0px; height: 0px; width: 0px;"></div>
 </div>
 <script type="text/javascript">
  <xsl:text>addScroller(getElement('spacer</xsl:text><xsl:value-of select="generate-id()"/><xsl:text>'), getElement('clipper</xsl:text><xsl:value-of select="generate-id()"/><xsl:text>'), getElement('scroller</xsl:text><xsl:value-of select="generate-id()"/><xsl:text>'), </xsl:text>
  <xsl:choose>
   <xsl:when test="not(element-available('speed')) or @speed = 'normal'">
    <xsl:text>30</xsl:text>
   </xsl:when>
   <xsl:when test="@speed = 'fastest'">
    <xsl:text>20</xsl:text>
   </xsl:when>
   <xsl:when test="@speed = 'fast'">
    <xsl:text>25</xsl:text>
   </xsl:when>
   <xsl:when test="@speed = 'slow'">
    <xsl:text>35</xsl:text>
   </xsl:when>
   <xsl:when test="@speed = 'slowest'">
    <xsl:text>40</xsl:text>
   </xsl:when>
  </xsl:choose>
 <xsl:apply-templates select="text" mode="scroll"/>
 <xsl:text>);</xsl:text>
 </script>
</xsl:template>
<xsl:template match="text" mode="scroll">
 <xsl:text>,"</xsl:text><xsl:value-of select="."/><xsl:text>"</xsl:text>
</xsl:template>
</xsl:stylesheet>
Thanks a lot for your help.
Evlich is offline   Reply With Quote
Old 01-25-2003, 07:07 PM   PM User | #2
mpjbrennan
Regular Coder

 
Join Date: Jun 2002
Location: Newcastle, England
Posts: 178
Thanks: 0
Thanked 0 Times in 0 Posts
mpjbrennan is an unknown quantity at this point
Can you not just generate a <script type="text/javascript" href="somefile.js"></script> line in your page and let that do the business for you?

patrick
mpjbrennan is offline   Reply With Quote
Old 01-25-2003, 07:46 PM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
I haven't run through your code specifically, but the general approach seems okay - I've done similair things - using XSL to generate a set of js arrays.

You might find that if you set the <xsl:output/> to text, it's easier to work with. But otherwise - what's actually the problem?
brothercake is offline   Reply With Quote
Old 01-25-2003, 08:35 PM   PM User | #4
Evlich
New Coder

 
Join Date: Jun 2002
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Evlich is an unknown quantity at this point
I can't just include another js file, I already do to get the function addScroller(), because the call has to be specific to the generate-id().
Evlich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:39 PM.


Advertisement
Log in to turn off these ads.