Subject: RE: [xsl] Re: XPath parsing or Extending MSXML From: "Robert Koberg" <rob@xxxxxxxxxx> Date: Fri, 13 Jun 2003 11:07:00 -0700 |
Hi, Since you are going to use Jscript you do something like: <abc> <a num="123"> <a num="545"> <a num="76"> </abc> var vals = docelem.selectNodes("//a"); var sum = 0; for (var i=0; I < values.length; i++) { var val = vals.item(i); var int = val.getAttribute("num"); sum += int; } Or perhaps (version 3): var e = new Enumerator(docelem.selectNodes("//a")); var sum = 0; for (;!e.atEnd();e.moveNext()) { x = e.item(); var int = new Number(x.getAttribute("num")); sum += int; } Best, -Rob > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- > list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Dimitre Novatchev > Sent: Friday, June 13, 2003 10:30 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > > > The MSXML4 parser can only return nodesets or single nodes when you give > it some XPath expression. I need the possibility to > use the sum, count > (and other functions) to get integer, string and boolean values as well. > > The XPath Visualizer (working with MSXML3) successfully obtains a string, > boolean or numeric result of XPath expressions. It is possible to use the > same technique with MSXML4, too. > > The possibilities to evaluate any XPath expression with the selectNodes() > and selectSingleNode() methods are even more limited than described -- > using > these methods it is not possible to evaluate an XPath expression, which > involves two or more completely independent node-sets -- e.g. find the > intersection or union of ns1 (contained in var objNodeList1) and ns2 > (contained in var objNodeList2). > > However, there are other ways to evaluate such XPath expressions -- the > Exslt for MSXML4 implementation is using one such technique. > > Therefore, I'd recommend studying the source code of the XPath Visualizer > and of Exslt for MSXML4. > > > ===== > Cheers, > > Dimitre Novatchev. > http://fxsl.sourceforge.net/ -- the home of FXSL > > > > > "Marcus Andersson" <marcan@xxxxxxx> wrote in message > news:009901c331c8$5b422e70$03a8a8c0@xxxxxxxxxxx > > Hello > > > > I have come to the point where I have to add some functionality to > MSXML4 > (in javascript) and it's capabilities to do XPath queries. The MSXML4 > parser > can only return nodesets or single nodes when you give it some XPath > expression. I need the possibility to use the sum, count (and other > functions) to get integer, string and boolean values as well. The only > solution I have come up with is to parse the XPath expression and build > some > object tree that I execute against the MSXML parser. So my question is: > Is > there any state diagram (I want to base the parser on it) publicly > available > for XPath or is the only solution to build this diagram to go through the > spec? > > > > If anyone has another solution (ie not evaluate with a state machine > based > parser) I will be more than happy to hear of it... > > > > /Marcus > > > > ps. I have thought of using XSLT to do this but I don't want to invoke > the > processor for every little calculation ds. > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > > > > > > > > > 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: XPath parsing or Extendin, Dimitre Novatchev | Thread | [xsl] expand conditional variable i, Xiaocun Xu |
[xsl] Re: XPath parsing or Extendin, Dimitre Novatchev | Date | Re: [xsl] call apply-templates to a, abbouh |
Month |