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

RE: How to get the name of the current element?

  • From: "Mike Sharp" <msharp@l...>
  • To: "Pierre, Sebastian" <spierre@R...>
  • Date: Sat, 20 May 2000 12:28:04 -0700

javascript get current element


Pierre,

It's very easy. In your XSL, while processing the <p> tag in the output (ie:
before the </p> tag), use the following:

<xsl:attribute name="class"><xsl:eval>fnTagName(this)</xsl:eval></xsl:attribute>


Then, at the top of the page, include a script block, like this:

<xsl:script language = "javascript"><![CDATA[
  function fnTagName(e) {
    return e.nodeName;
  }
]]></xsl:script>

You'll find that this works even with the first MSXML parser.  You could get
even trickier and include the whole thing in the same xsl:eval tag, but I prefer
to abstract the function so that it can be re-used.

As a side note, if you want to do client side XML transformations, you don't
have a great deal of choice other than IE5.  In my opinion, they did a pretty
good job on it, considering the timeframe.  I've been able to do some amazing
things in the user interface using XML and XSL in IE 5; things that I never
would have though possible before.  I don't know about the other UI developers
out there using XML on the client, but I haven't been this excited about a
technology in a long time.

Although I may someday find something that is not possible, I haven't found it
yet--at least I've been able to more than satisfy even the most extreme of
customer requests.  A determined developer can accomplish a lot if he or she
believes that it's possible.  Just remember that you can totally manipulate the
DOM using script, or a combination of script and XSL.  If there is something you
need to do, and you think it can't be done, that usually means only that you
haven't figured it out yet.  For example, three of the MSXML extensions to the
W3C DOM, selectNodes(), selectSingleNode() and transformNode() are incredibly
useful for UI work.

Regards,
Mike Sharp

Senior Site Developer
Lante Corporation






"Pierre, Sebastian" <spierre@R...> on 05/19/2000 06:19:17 PM

To:   Peter Armstrong <armstrong@e...>
cc:   XML-Dev ML <xml-dev@x...> (bcc: Mike Sharp/Lante)

Subject:  RE: How to get the name of the current element?




You're completely true to say -MS-XML, because it is far from being XML ;)

 | No.  I was assuming you were doing this server-side (e.g. with Cocoon).
 | Maybe one of the MS people on this list can help you--I don't know
 | anything about MSXML.
 |







***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.