You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by David Fishburn <fi...@ianywhere.com> on 2004/08/13 16:38:32 UTC

JavaScript inside of XSL

Apologies for not having done my homework, but I thought I would field a
quick question.
I haven't been working on this project for sometime, so I would have to get
back into it.

I am using Xerces 2.5.0.
I believe I am using Xalan 1.8.0, not sure how to check since the directory
name I unzipped does not have the version # in it.

At least with earlier versions, when I attempted to add some JavaScript
validation to my XSL, I received parse errors.

Here is a simple example that I did:

    <xsl:template name="CENTER_DATA">
        <!-- Replace the following part with your logic, the sample code
shows one record only! -->
        <!--
        <SCRIPT LANGUAGE="JavaScript">

          function runSubmit (form,button) {
            if (!check(form)) return;
            document.Group.submit();
            return;
          }

          function check(form) {
            result = true
            //If a player is selected from the list OR a handicap index is
entered
            //make sure a course is selected OR a course slope is provided.
            //For ALL players
            if ( ((form.p1hi.value.length > 0) || (form.p1DBhi.selectedIndex
> 0)) && (result) ) {
              if ( (form.p1sl.value.length == 0) && (form.ck.selectedIndex
== 0) ) {
                alert ("Must enter a course slope for Player 1.");
                form.p1sl.focus();
                result = false;
              }
            }

            return( result );
          }
        </SCRIPT>
        -->

        <FORM ACTION="group_handicap_display" NAME="log" METHOD="GET">

          <table>
            <tr>
              <td align="center">
                <H2>Group Handicap Calculator</H2>
              </td>
            </tr>
            <tr>
              <!--table borderColor='#ffe4b5' border='2'-->
              <table border='2'>
                  <th></th>
                  <th>Player 1</th>
                  <th>Player 2</th>
                  <th>Player 3</th>
                  <th>Player 4</th>
                <tr>
                  <td>Player:</td>
                  <td>
                    <SELECT NAME="pk1">
                      <xsl:for-each select="DATA/player" >
                        <OPTION VALUE="{player.player_key}">
                          <xsl:value-of select="player.player_name" />
                        </OPTION>
                      </xsl:for-each>
                    </SELECT>
                  </td>
                  <td>
                    <SELECT NAME="pk2">
                      <xsl:for-each select="DATA/player" >
                        <OPTION VALUE="{player.player_key}">
                          <xsl:value-of select="player.player_name" />
                        </OPTION>
                      </xsl:for-each>
                    </SELECT>
                  </td>
                  <td>
                    <SELECT NAME="pk3">
                      <xsl:for-each select="DATA/player" >
                        <OPTION VALUE="{player.player_key}">
                          <xsl:value-of select="player.player_name" />
                        </OPTION>
                      </xsl:for-each>
                    </SELECT>
                  </td>
                  <td>
                    <SELECT NAME="pk4">
                      <xsl:for-each select="DATA/player" >
                        <OPTION VALUE="{player.player_key}">
                          <xsl:value-of select="player.player_name" />
                        </OPTION>
                      </xsl:for-each>
                    </SELECT>
                  </td>
                </tr>
                <tr>
                  <td>Course:</td>
                  <td colspan="4" align="center">
                    <SELECT NAME="ck">
                      <xsl:for-each select="DATA/course" >
                        <OPTION VALUE="{course.course_key}">
                          <xsl:value-of select="course.course" />
                        </OPTION>
                      </xsl:for-each>
                    </SELECT>
                  </td>
                </tr>
                <tr>
                  <td>Handicap Index:</td>
                  <td>
                    <INPUT TYPE="text" NAME="p1hi" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p2hi" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p3hi" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p4hi" SIZE="4" VALUE=""/>
                  </td>
                </tr>
                <tr>
                  <td>Course Slope:</td>
                  <td>
                    <INPUT TYPE="text" NAME="p1sl" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p2sl" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p3sl" SIZE="4" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p4sl" SIZE="4" VALUE=""/>
                  </td>
                </tr>
                <tr>
                  <td>Name:</td>
                  <td>
                    <INPUT TYPE="text" NAME="p1name" SIZE="20" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p2name" SIZE="20" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p3name" SIZE="20" VALUE=""/>
                  </td>
                  <td>
                    <INPUT TYPE="text" NAME="p4name" SIZE="20" VALUE=""/>
                  </td>
                </tr>
                <tr>
                  <td align="center" colspan="5">
                    <!--input TYPE="submit" VALUE="Submit"
onClick="runSubmit(this.form, this)"/-->
                    <input TYPE="submit" VALUE="Submit" />
                  </td>
                </tr>
              </table>
              <H3>Choose a player OR enter a handicap index. </H3>
              <H3>Choose a course OR enter a course slope. </H3>
              <A HREF="main">Main Menu</A>
            </tr>
          </table>

        </FORM>

    </xsl:template>


If I uncomment the JavaScript section then the I get errors when trying to
use the page.
I dont have the error handy, but thought I would ask first to see if there
is something I am obviously doing wrong.

Thanks in advance for any help provided.

Dave


RE: JavaScript inside of XSL

Posted by Surajit Bhattacharyya <su...@yahoo.com>.
Hi David, 
I made an entry on xalan compilation problems with
solaris. I see that you provide solutiuons for a lot
of problems. Could you pls have a look at my issues
and give me any directions.
Thanks and Regards
Surajit
--- David Fishburn <fi...@ianywhere.com> wrote:

> Right, thanks.
> 
> I replaced:
> 	&&
> With:
> 	&amp;&amp;
> 
> Based on this webpage, which does a good job of
> listing which items need
> escaping and what values to use.
>
http://www.htmlhelp.com/reference/html40/entities/special.html
> 
> Dave
>  
> 
> > -----Original Message-----
> > From: Keith Rogers [mailto:k_a_rogers@yahoo.com] 
> > Sent: Friday, August 13, 2004 11:09 AM
> > To: xalan-c-users@xml.apache.org
> > Subject: Re: JavaScript inside of XSL
> > 
> > You have to use entities in the script, like &gt;
> instead of the ">"
> > characters, unless you wrap it it in <![CDATA[ ...
>  ]> .
> > 
> 
> 



		
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

RE: JavaScript inside of XSL

Posted by David Fishburn <fi...@ianywhere.com>.
Right, thanks.

I replaced:
	&&
With:
	&amp;&amp;

Based on this webpage, which does a good job of listing which items need
escaping and what values to use.
http://www.htmlhelp.com/reference/html40/entities/special.html

Dave
 

> -----Original Message-----
> From: Keith Rogers [mailto:k_a_rogers@yahoo.com] 
> Sent: Friday, August 13, 2004 11:09 AM
> To: xalan-c-users@xml.apache.org
> Subject: Re: JavaScript inside of XSL
> 
> You have to use entities in the script, like &gt; instead of the ">"
> characters, unless you wrap it it in <![CDATA[ ...  ]> .
> 


Re: JavaScript inside of XSL

Posted by Keith Rogers <k_...@yahoo.com>.
You have to use entities in the script, like &gt; instead of the ">"
characters, unless you wrap it it in <![CDATA[ ...  ]> .