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

Re: Questions about using JScript in XSL

Subject: Re: Questions about using JScript in XSL
From: "Frank Boumphrey" <bckman@xxxxxxxxxxxxx>
Date: Thu, 9 Apr 1998 10:08:05 -0700
jscript in xsl
>>Doesn't the document object model spec
for XML say that getAttribute returns 'null' if the attribute doesn't
exist?<<

I think that Johnathan Marsh pointed out a day or too back that this is a
bug in msxml, it does not return null it returns an error.
Frank

"If memory serves, there is a bug in the getAttribute
function; if the
targeted attribute is not present on any of the target
elements, you get
the error below. MS knows about it.

Daniel
Yes, this is true.  If you have "year" elements without "which" attributes
or "event" elements without "status" elements MSXSL will generate this error
instead of returning null.  The easiest workaround in this case would be to
make sure these attributes are always present.

Jonathan Marsh"

-----Original Message-----
From: Barry MacKichan <barrym@xxxxxxxxxxx>
To: XSL List <XSL-List@xxxxxxxxxxxxxxxx>
Date: Wednesday, April 08, 1998 8:45 PM
Subject: Questions about using JScript in XSL


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


 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.