📄 overview-summary-sarissa_ieemu_xpath.js.html
字号:
* (moz will rezolve non-default namespaces by itself). You will need to map that * namespace to a prefix for queries to work.</p> * <p><b>Note 2 </b>: This method calls IE's setProperty method to set the * appropriate namespace-prefix mappings, so you dont have to do that.</p> * <span class="attrib">@param</span> oDoc The target XMLDocument to set the namespace mappings for. * <span class="attrib">@param</span> sNsSet A whilespace-seperated list of namespace declarations as * those would appear in an XML document. E.g.: * <code>&quot;xmlns:xhtml=&apos;http://www.w3.org/1999/xhtml&apos; * xmlns:&apos;http://www.w3.org/1999/XSL/Transform&apos;&quot;</code> * <span class="attrib">@throws</span> An error if the format of the given namespace declarations is bad. */</span> Sarissa.setXpathNamespaces = <span class="reserved">function</span>(oDoc, sNsSet) { <span class="comment">//oDoc._sarissa_setXpathNamespaces(sNsSet);</span> oDoc._sarissa_useCustomResolver = true; var namespaces = sNsSet.indexOf(<span class="literal">" "</span>)>-1?sNsSet.split(<span class="literal">" "</span>):new Array(sNsSet); oDoc._sarissa_xpathNamespaces = new Array(namespaces.length); <span class="reserved">for</span>(var i=0;i < namespaces.length;i++){ var ns = namespaces[i]; var colonPos = ns.indexOf(<span class="literal">":"</span>); var assignPos = ns.indexOf(<span class="literal">"="</span>); <span class="reserved">if</span>(colonPos > 0 && assignPos > colonPos+1){ var prefix = ns.substring(colonPos+1, assignPos); var uri = ns.substring(assignPos+2, ns.length-1); oDoc._sarissa_xpathNamespaces[prefix] = uri; }<span class="reserved">else</span>{ throw <span class="literal">"Bad format on namespace declaration(s) given"</span>; }; }; }; <span class="comment">/** * <span class="attrib">@private</span> Flag to control whether a custom namespace resolver should * be used, set to true by Sarissa.setXpathNamespaces */</span> XMLDocument.<span class="reserved">prototype</span>._sarissa_useCustomResolver = false; <span class="comment">/** <span class="attrib">@private</span> */</span> XMLDocument.<span class="reserved">prototype</span>._sarissa_xpathNamespaces = new Array(); <span class="comment">/** * <p>Extends the XMLDocument to emulate IE's selectNodes.</p> * <span class="attrib">@argument</span> sExpr the XPath expression to use * <span class="attrib">@argument</span> contextNode this is for internal use only by the same * method when called on Elements * <span class="attrib">@returns</span> the result of the XPath search as a SarissaNodeList * <span class="attrib">@throws</span> An error if no namespace URI is found for the given prefix. */</span> XMLDocument.<span class="reserved">prototype</span>.selectNodes = <span class="reserved">function</span>(sExpr, contextNode, returnSingle){ var nsDoc = <span class="reserved">this</span>; var nsresolver = <span class="reserved">this</span>._sarissa_useCustomResolver ? <span class="reserved">function</span>(prefix){ var s = nsDoc._sarissa_xpathNamespaces[prefix]; <span class="reserved">if</span>(s)<span class="reserved">return</span> s; <span class="reserved">else</span> throw <span class="literal">"No namespace URI found for prefix: '"</span> + prefix+<span class="literal">"'"</span>; } : <span class="reserved">this</span>.createNSResolver(<span class="reserved">this</span>.documentElement); var result = null; <span class="reserved">if</span>(!returnSingle){ var oResult = <span class="reserved">this</span>.evaluate(sExpr, (contextNode?contextNode:<span class="reserved">this</span>), nsresolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); var nodeList = new SarissaNodeList(oResult.snapshotLength); nodeList.expr = sExpr; <span class="reserved">for</span>(var i=0;i<nodeList.length;i++) nodeList[i] = oResult.snapshotItem(i); result = nodeList; } <span class="reserved">else</span> { result = oResult = <span class="reserved">this</span>.evaluate(sExpr, (contextNode?contextNode:<span class="reserved">this</span>), nsresolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; }; <span class="reserved">return</span> result; }; <span class="comment">/** * <p>Extends the Element to emulate IE's selectNodes</p> * <span class="attrib">@argument</span> sExpr the XPath expression to use * <span class="attrib">@returns</span> the result of the XPath search as an (Sarissa)NodeList * <span class="attrib">@throws</span> An * error if invoked on an HTML Element as this is only be * available to XML Elements. */</span> Element.<span class="reserved">prototype</span>.selectNodes = <span class="reserved">function</span>(sExpr){ var doc = <span class="reserved">this</span>.ownerDocument; <span class="reserved">if</span>(doc.selectNodes) <span class="reserved">return</span> doc.selectNodes(sExpr, <span class="reserved">this</span>); <span class="reserved">else</span> throw <span class="literal">"Method selectNodes is only supported by XML Elements"</span>; }; <span class="comment">/** * <p>Extends the XMLDocument to emulate IE's selectSingleNode.</p> * <span class="attrib">@argument</span> sExpr the XPath expression to use * <span class="attrib">@argument</span> contextNode this is for internal use only by the same * method when called on Elements * <span class="attrib">@returns</span> the result of the XPath search as an (Sarissa)NodeList */</span> XMLDocument.<span class="reserved">prototype</span>.selectSingleNode = <span class="reserved">function</span>(sExpr, contextNode){ var ctx = contextNode?contextNode:null; <span class="reserved">return</span> <span class="reserved">this</span>.selectNodes(sExpr, ctx, true); }; <span class="comment">/** * <p>Extends the Element to emulate IE's selectSingleNode.</p> * <span class="attrib">@argument</span> sExpr the XPath expression to use * <span class="attrib">@returns</span> the result of the XPath search as an (Sarissa)NodeList * <span class="attrib">@throws</span> An error if invoked on an HTML Element as this is only be * available to XML Elements. */</span> Element.<span class="reserved">prototype</span>.selectSingleNode = <span class="reserved">function</span>(sExpr){ var doc = <span class="reserved">this</span>.ownerDocument; <span class="reserved">if</span>(doc.selectSingleNode) <span class="reserved">return</span> doc.selectSingleNode(sExpr, <span class="reserved">this</span>); <span class="reserved">else</span> throw <span class="literal">"Method selectNodes is only supported by XML Elements"</span>; }; Sarissa.IS_ENABLED_SELECT_NODES = true;};</pre> <hr><!-- ========== START OF NAVBAR ========== --><a name="navbar_top"><!-- --></a><table border="0" width="100%" cellpadding="1" cellspacing="0"><tr><td colspan=2 bgcolor="#b8cade" class="NavBarCell1"><a name="navbar_top_firstrow"><!-- --></a><table border="0" cellpadding="0" cellspacing="3"> <tr align="center" valign="top"> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td> <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> <td bgcolor="#b8cade" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td> </tr></table></td><td bgcolor="#b8cade" align="right" valign="top"><em><b>sarissa</b></em></td></tr><tr><td bgcolor="#eeeeee" class="NavBarCell2"><font size="-2"> PREV NEXT</font></td><td bgcolor="#eeeeee" class="NavBarCell2"><font size="-2"> <a href="index.html" target="_top"><b>FRAMES</b></a> <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> <script> <!-- if(window==top) { document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>'); } //--></script><noscript><a href="allclasses-noframe.html" target=""><b>All Classes</b></a></noscript></font></td></tr></table><!-- =========== END OF NAVBAR =========== --><hr><font size="-1"></font><div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Thu Nov 30 22:06:11 2006</div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -