SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : XML Technologies :

Previous DiscussionNext Discussion
 XSL & XML in FireFox

HI,

I have an application in IE and I'm moving it to FireFox.

There is one section I didn't find match functionality:

currSort1DirNodeVal = xsl.documentElement.selectSingleNode("//xsl:param[@name=\"sort1Dir\"]/@select").nodeValue;

xsl example is:

......................

<?xml version="1.0" ?>

- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:param name="sortByDummy" select="' '" />
  <xsl:param name="sort1By" select="'time'" />
  <xsl:param name="sort1Dir" select="'ascending'" />
  <xsl:param name="sort1Type" select="'number'" />
  <xsl:param name="sort2By" select="' '" />
  <xsl:param name="sort2Dir" select="'ascending'" />

..................................

Can you help

 

thanks :-)

 

Started By en on Jan 18, 2006 at 5:03:13 AM

14 Response(s) | Reply

Earlier Replies | Replies 8 to 14 of 14 | Later Replies
Goto Page: 2 1
BachusII on Jan 19, 2006 at 8:41:47 AM (# 8)

Crazily enough most examples of document.evaluate employ their own selfmade functions to resolve. I found createNSResolver while writing my own resolver. (Which reminds me that I need to update that page with my findings.)


Jack Turk on Jan 20, 2006 at 3:16:39 AM (# 9)


en on Jan 23, 2006 at 12:57:26 AM (# 10)

Hi

thanks for your answer....

However it still give me this problem

": uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.createNSResolver]"  nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)"  location: "JS frame :: file:///d:/profiles/ben010/Desktop/Event%20Lo_files/eventloggertable.htm :: loadXML :: line 79"  data: no]"

 

my code is:

 

var xsl = document.implementation.createDocument("","",null);

xsl.load("eventlogger.xsl");

var currSort1DirNodeVal = xsl.evaluate("//xsl:param[@name=\"sort1By\"]/@select", xsl.createNSResolver( xsl.documentElement ) , null, 9,null).singleNodeValue

Thanks....


BachusII on Jan 23, 2006 at 1:29:24 AM (# 11)

Your arguments are wrong, both in sequence and meaning. Try the link in reply #8.


ARWolff on Jan 23, 2006 at 4:39:40 AM (# 12)
This message has been edited.

To make the script work cross-browser, here's an includable bit to add the MS parser's selectNodes to the Mozilla DOM object. I like this method better, because it allows a simple way to check the existence of matching nodes, e.g.

var myNodes=xsl.documentElement.selectNodes("//xsl:param[@name=\"sort1Dir\"]");
if(myNodes.length>0){
     currSort1DirNodeVal = myNodes[0].getAttribute["select"];
}else{
      // Data missing
}

Include this script to use selectNodes in IE, NS & FF:


/*
Prefix-correcting evaluate statement from http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/119
*/

if( document.implementation.hasFeature("XPath", "3.0") ){
 XMLDocument.prototype.selectNodes = function(cXPathString, xNode){
  if( !xNode ) {
   xNode = this;
  }
    
  var defaultNS = this.defaultNS;

  var aItems = this.evaluate(cXPathString, xNode,{
   normalResolver:
    this.createNSResolver(this.documentElement),
        lookupNamespaceURI : function (prefix) {
           switch (prefix) {
             case "dflt":
                return defaultNS;
             default:
                return this.normalResolver.lookupNamespaceURI(prefix);
           }
        }
      },XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);

  var aResult = [];
  for( var i = 0; i < aItems.snapshotLength; i++){
           aResult[i] =  aItems.snapshotItem(i);
  }
  return aResult;
 }

 Element.prototype.selectNodes = function(cXPathString){
  if(this.ownerDocument.selectNodes){
   return this.ownerDocument.selectNodes(cXPathString, this);
  }else{
   throw "For XML Elements Only";
  }
 }

 /* set the SelectionNamespaces property the same for NN or IE: */
 XMLDocument.prototype.setProperty = function(p,v){
  if(p=="SelectionNamespaces" && v.indexOf("xmlns:dflt")==0){
   this.defaultNS = v.replace(/^.*=\'(.+)\'/,"$1");
  }
 }

 XMLDocument.prototype.defaultNS;

}


mikejr83 on May 9, 2006 at 9:25:52 AM (# 13)

After reading many articles on this subject I have yet to find a "good" solution in such that it does not crash in FF. I have seen the above code in many different websites. I've used this one and several others. On my current implementation the code breaks on the similar spot in the above code:

this.createNSResolver(this.documentElement),

The error I get:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMXPathEvaluator.createNSResolver]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://localhost:3421/MVP%20Testing%20Items/mozxpath.js :: anonymous :: line 10" data: no]

Line 10 being:

var oNSResolver = this.createNSResolver(this.documentElement)

I do not know why this keeps happening. I've been looking into why this error is being generated. If someone could elaborate it would be much appreciated.

Mike


BachusII on May 9, 2006 at 9:43:39 AM (# 14)

Use the document to which this belongs, not this.


Earlier Replies | Replies 8 to 14 of 14 | Later Replies
Goto Page: 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.