0

I'm using JavaScript to apply a xslt transformation to a xml file to return a json object in a specific format.

I'm using the following code to test the process:

var xml = loadDoc("my.xml"); //custom function that loads the xml and xsl docs these are working
var xsl = loadDoc("my.xsl");

var processor = new XSLTProcessor();
processor.importStylesheet(xsl);
var result = processor.transformToDocument(xml);

console.log(result);

I've tested the code with a couple of very simple xml and xsl files with success however the console log outputs a null when I'm testing it with the xsl document and xml I'm supposed to use, they were not prepared by me and I have very little experience with xslt transformations.

I've tested those files using a couple of online tools and they worked on a couple of them but others were unable to perform the transformation. (http://xslttest.appspot.com/ this can run the transformation without a problem but not this one http://www.freeformatter.com/xsl-transformer.html)

2
  • 1
    Does the stylesheet use XSLT version="2.0"? Browsers only support version 1.0. What happens when you try freeformatter.com/xsl-transformer.html, do you get any error message? Can you post the stylesheet code or a link to it? Commented May 27, 2014 at 16:46
  • It does not use versio 2.0. Using that tool I get "Unable to perform XSL transformation on your XML file. null". Here is the file I'm using: test53.comlu.com/file.xsl Commented May 27, 2014 at 17:13

1 Answer 1

1

That stylesheet uses XSLT 2.0 features like xsl:function so don't expect any XSLT 1.0 processor like the one in browsers to be able to execute that code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.