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
>>Doesn't the document object model spec
for XML say that getAttribute returns 'null' if the attribute doesn't

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.

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

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
>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
>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
>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
>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 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
>this simple task in JScript.
>--Barry MacKichan
> XSL-List info and archive:

 XSL-List info and archive:

Current Thread