views:

70

answers:

1

Hi,

I am trying to pass into an JavaScript function two paths for an XML and XSLT. It would appear that in the sample HTML below that the use of "../xsl/filename" does not work for me in the xslt() function. If I specify the path as being "./filename" though this does work.

Does anyone know how I can work around this or find some way that I can specify a sibling folder without an absolute path reference? I would prefer not to have to change my file paths as my development environment is set up with the xslt's, sample data and source code structured in a particular way.

Thanks in advance Jamen

<html>
<head>
<title></title>
<script type="text/javascript" src="../lib/jsunit/app/jsUnitCore.js"></script>
<script type="text/javascript" src="../lib/jquery-1.2.3.js"></script>
<script type="text/javascript" src="../lib/jquery.xslt.js"></script>
</head>
<body>
<div id="bla"></div>
<script type="text/javascript">
$('#bla').xslt("../sampledata/response1.xml", "../xslt/resultFormatter.xsl");

//function testjQuery() {
//  $('#bla').xslt("../sampledata/response1.xml", "../xslt/resultFormatter.xsl");
//}
</script>
</body>
</html>
A: 

A live example would give me the quickest way to drill down on this, but in lieu of that..

You're going to have to do a bit of debugging, I'm afraid.

You can reference relative paths at least one level deep because the headers pulling in the JS source files do that too, so that rules out issues with the webserver.

Processing and pulling in resources seems to happen client-side, so open up a Firebug console or something else that gives you a view of what's happening in your JS environment.

If you draw a blank there, dig into the source.

Take a look at the source code in,

http://johannburkard.de/software/xsltjs/apidoc/overview-summary-jquery.xslt.js.html

There are two different paths,

if (document.recalc) { // IE 5+
    // EDIT : Path 1 
} else if ( /* EDIT : conditions */) { // Mozilla 0.9.4+, Opera 9+
    // EDIT : Path 2 
} // EDIT : No final else, so a silent failure

The second parameter that's giving you grief is matched against the regex,

var str = /^\s*</;

in both paths. Whichever path you're going down, set a breakpoint and test these cases yourself (with both the xslt parameter values you've been using). Eliminate possibilities and keep going down the processing chain until you find your failure point.

I'd guess that there's a regex match/string handling bug somewhere down the line where the original author didn't anticipate relative paths.

Michiel Kalkman