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

Highlighting individual elements through script..

Subject: Highlighting individual elements through script..
From: Nicolas Pottier <nic@xxxxxxxxxx>
Date: Thu, 20 May 1999 13:13:00 -0700
javascript highlight elements
Hello everybody..

Well, I've been hacking away at this XSL stuff for a couple days now and
have done some relatively interesting things with it, but I seem to be
stuck again.  I currently have an XSL file which will use some script
and stylesheets in order to highlight or unhighlight the people in a
file in response to a click. (see below for the XML and XSL files)  This
is pretty cool stuff, and I'm happy with it, but I want to go one step
further and am completely stuck.  First off, my example XML file
represents a documnet, with the people in each sentence tagged, as well
as a list of unique people for the document.  I would like to be able to
have a specific person highlight in respone to a user clicking on it. 
IE, if they click on Jill in the example below, I would like all Jill
(key="1") PERSONs to turn bold or something.  As of right now I really
don't have any clues on doing this.  Can anybody help?

My platform is IE5.0, though I do have XT running now as well.

-Nic (files follow)

---XML FILE---

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="paragraph.xsl" ?>
<SENTENCE>Grumpy <PERSON key="0">Jack</PERSON> went up the
<SENTENCE>Angry <PERSON key="1">Jill</PERSON> followed him and took a
nasty spill.</SENTENCE>
<SENTENCE>Poor <PERSON key="0">Jack</PERSON>, now he has to carry
<PERSON key="0">Jack</PERSON>
<PERSON key="1">Jill</PERSON>

---XML FILE---

And an XSL File which looks like this:

---XSL FILE---

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="/">

    <SCRIPT language="JavaScript">
          function highlightPeople() {
	    unpeopleLink.style.display = "block";
	    peopleLink.style.display = "none";
	    document.styleSheets[0].rules[0].style.backgroundColor =
          function unhighlightPeople() {
	    peopleLink.style.display = "block";
	    unpeopleLink.style.display = "none";
	    document.styleSheets[0].rules[0].style.backgroundColor = "white";

    <STYLE TYPE="text/css">
      .people {backgroundColor:"white"}

      <xsl:apply-templates select="DOCUMENT/PARAGRAPH/SENTENCE"/>
      <xsl:apply-templates select="DOCUMENT/PEOPLE/PERSON"/>
      <SPAN ID="peopleLink">
        <A HREF="javascript:highlightPeople();">
	  Highlight People
      <SPAN ID="unpeopleLink" STYLE="display:none">
        <A HREF="javascript:unhighlightPeople();">
	  Unhighlight People

  <!-- Start of default XSL templates which IE should include but doesnt

  <xsl:template match="text()">

  <xsl:template match="*">

  <!-- End of default XSL templates which IE should include but doesnt

  <xsl:template match="SENTENCE">

  <xsl:template match="PEOPLE/PERSON">

  <xsl:template match="SENTENCE/PERSON">
    <SPAN CLASS="people"><xsl:apply-templates/></SPAN>



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

Current Thread


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.
First Name
Last Name
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.