Hey, folks,

Does anyone have a clue why the following might be happening, and better
yet, what I can do to avoid it?  My platform info is MacOS 10.2.3, Mozilla
5.0 Gecko/20021120 Netscape 7.1.

I'm trying to add a prototype selectSingleNode() method to the Element
object and have run up against this error when I try to execute it:

Error: [Exception... "'Permission denied  to get property
XPathResult.singleNodeValue' when calling method
[nsIDOMEventListener::handleEvent]" nsresult "0x8057001e
(NE_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]

The code looks like this:

<script>

  doc = document.implementation.createDocument("","", null);
  doc.addEventListener("load", documentLoaded, false);

  doc.load("../../data/sample4_for_edit.xml", "text/xml");


  function documentLoaded()
  {
   doc.documentElement.constructor.prototype.selectSingleNode =
Element_selectSingleNode;
   alert( doc.documentElement.selectSingleNode("content/chapter/title") );
  }

  function Element_selectSingleNode( xpath )
  {
   xPathResult = this.ownerDocument.evaluate(xpath, this, null, 9, null);
   return xPathResult.singleNodeValue;
  }

 </script>

I've tried doing an enablePermission("SuperUser"), which didn't help.  I
also tried an alternate form of the Element_selectSingleNode() function that
looked like:

  function Element_selectSingleNode( xpath )
  {
   currNode = this;
   nodeNames = xpath.split("/");
   for ( x = 0; x < nodeNames.length; x++ )
   {
    n = currNode.getElementsByTagName( nodeNames[x] );
    if ( n.length == 0 )
    {
     return null;
    }
    currNode = n[0];
   }
   return currNode;
  }


In this case, I get the same exception, only for the n.length call.



Reply via email to