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

Questions about using JScript in XSL

Subject: Questions about using JScript in XSL
From: "Barry MacKichan" <barrym@xxxxxxxxxxx>
Date: Wed, 8 Apr 1998 19:44:03 -0700
xsl jscript
I'm using Microsoft's msxsl.

I have a link to another element (<A HREF=#theID>), and I need to compute
the section number that contains the element with ID==theID.  Once I have
the target element, computing the section number is trivial:

n = childNumber(ancestor("section", target)); or I guess I can use
'ancestorChildNumber'

My question is, how can I find the target?  In a well-formed XML document,
the ID is unique, so I should be able to find it with something analogous to
DHTML's  document.all("theID").  Since there is no documented function that
I can find, I tried a recursive search starting at the root.  It contains
the test

if ("theID" == e.getAttribute("ID"))

This causes a crash (a <script error> in the debugger) when e is an element
that doesn't have an ID attribute.  Doesn't the document object model spec
for XML say that getAttribute returns 'null' if the attribute doesn't exist?

Well, I know that the type of the target element is one of a small list of
element types.  So I can try to prevent the crash by testing for the element
type:

if (e.tagName == ... || e.tagName == ...) ...

The problem is that *this* crashes when e is a text leaf, and I don't know
how to test the children of the node to see which ones are text and which
ones are other elements.

In view of these problems, with no 'try' and 'catch' mechanism, and with no
'hasAttribute' or 'hasTagName', it seems to me that writing significant
JScript scripts is doomed...at least until the object model subset is
extended significantly.

I hope that there is part of the spec or the documentation that I have
misread or missed entirely.  Please let me know if there is a way to perform
this simple task in JScript.

--Barry MacKichan



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


Current Thread

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
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.