Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8111937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:18:11+00:00 2026-06-06T02:18:11+00:00

I am currently trying to get multiple xml files into my xsl file to

  • 0

I am currently trying to get multiple xml files into my xsl file to then process them into useful html. This works fine for non webkit browsers but not for webkit browsers.

I am using JavaScript to perform the transformation and it works fine across all browsers apart from if I want multiple xml files in it.

I have tried various methods to try and get the extra xml files into the xsl, the files are all on the same server but in different folders.

1) I have tried adding the xml files directly as a variable. For example:

<xsl:variable name="structure" select="document('../structure.xml')"/> 

I have since found that webkit browsers do not allow this as it’s considered a security risk. But if anyone is aware of any workarounds or different methods to achieve the same result that would be great

2) I have tried passing the xml file through into the processor as a parameter. Eg:

xml=loadXMLDoc("structure.xml);
xsl=loadXMLDoc("xsl/head.xsl");
structurexml =loadXMLDoc("/extranet/structure.xml");
xsltProcessor =new XSLTProcessor();
xsltProcessor.importStylesheet(xsl);
xsltProcessor.setParameter(null, "structure", structurexml);
process.transform();

loadXMLDoc is a simple piece of code that loads the xml and xsl files

function loadXMLDoc(fname) {
var isIE = (navigator.appName=="Microsoft Internet Explorer");
if (window.XMLHttpRequest) {
    xhttp = new XMLHttpRequest();
}
else {
  xhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xhttp.open('GET', fname, false);
if (xhttp.overrideMimeType){
  xhttp.overrideMimeType('text/xml');   
}
xhttp.send(null);
if (isIE) {
  xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
  xmlDoc.async = false;
  xmlDoc.load(fname);
}
else {
  xmlDoc = xhttp.responseXML;
  if (!xmlDoc) {
    xmlDoc = (new DOMParser()).parseFromString(xhttp.responseText, 'text/xml');
  }
}
return xmlDoc;
}

This doesn’t work as webkit doesn’t allow node-set as a parameter. Again any kind of work around would be brilliant

3) I have tried the above but transformed the xml into a string before adding as a parameter. This allows me to get the parameter to be passed through but then I can’t get the string to be transformed back into xml to then process it.

If anyone has any ideas about this that would also be great.

The other option I have thought of is to use JavaScript to merge the xml files into one giant one and process this but I have no idea how to do that.

Also I can’t do server side processing as I do not have control of the server so I am left with only client side.

As I said before I can solve the problem for non webkit browsers. I have been trying to solve this problem for a while now and can’t find any workarounds. I can’t see that I can be the only person with this problem and really hope that someone has had a similar problem and found a workaround or fix for this.

Thanks in advance!

Matt


UPDATE:

I have also thought about adding the xml files together in JavaScript.

xml=loadXMLDoc("structure.xml);
xsl=loadXMLDoc("xsl/head.xsl");
structurexml =loadXMLDoc("/extranet/structure.xml");
newxml = xml;
newxml.appendChild(sessionxml);

But get an error of Uncaught Error: HIERARCHY_REQUEST_ERR: DOM Exception 3 which I believe is due to the fact that there would be no root node in the new xml? Does anyone know how I would be able to successfully add them? The two files are

<?xml version="1.0" encoding="utf-8"?>
<structure>
  <product>
    <id>1</id>
    <unit>
        <id>1</id>
        <name>Blah</name>
        <code>Blah</code>
    </unit>
  </product>
</structure>

and

<?xml version="1.0" encoding="utf-8"?>
<user>
  <emp>true</emp>
  <first>Test</first>
  <last>User</last>
</user>

Ideally I would like to have the file in the format

<?xml version="1.0" encoding="utf-8"?>
<root>
  <structure>
    <product>
      <id>1</id>
      <unit>
          <id>1</id>
          <name>Blah</name>
          <code>Blah</code>
      </unit>
    </product>
  </structure>
  <user>
    <emp>true</emp>
    <first>Test</first>
    <last>User</last>
  </user>
</root>

Is there a simple way to achieve this in JavaScript or JQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T02:18:12+00:00Added an answer on June 6, 2026 at 2:18 am

    Saxon-CE is an XSLT 2.0 processor (compiled to JavaScript) that will run in webkit and all the major browsers and (naturally) supports the document() function. As well as atomic values it also supports documents, nodes, arrays or even JavaScript objects being passed as parameters.

    You could run the transform using code very similar to your own, but using:

     xsltProcessor = Saxon.createXSLT20Processor();
    

    however the following JavaScript could also be used

    Saxon.run({
       stylesheet: "xsl/head.xsl",
       source:     "structure.xml",
       parameters: {
                        structure: Saxon.requestXML("/extranet/structure.xml");
                   }
    
    });
    

    The ‘structure’ parameter is just for illustrative purposes, in your case you just need to use the document() function normally within the XSLT.

    I should also mention that with Saxon-CE updates to an HTML document can be done using the standard XSLT 2.0 xsl:result-document instruction. So if you want to update a DIV element with an id of ‘head’ by adding a paragrah you could use:

    <xsl:result-document href="#head" method="append-content">
       <p>Book Title: <xsl:value-of select="$title"/></p>
    </xsl:result-document>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to get the output of an executable console-app into an other
I'm currently trying to write a multiple-file Python (2.6.5) game using PyGame. The problem
I'm trying to get multiple lines in a listView I currently have the following
i am trying to get a list of files into an array or list
I am currently trying to get data out of a plist. It basically looks
I'm currently trying to get a grip on Android development and working my way
i am currently trying to get Input Mode Editor (IME) support working with a
I am currently trying to get my server to create a connection with a
I'm currently trying to get ActiveAdmin to work on a model of mine but
I'm currently trying to get my head around MUI, and getting some issues with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.