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

  • Home
  • SEARCH
  • 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 3355134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:21:30+00:00 2026-05-18T02:21:30+00:00

I’ve got an xml file. It is meant for being transformed by xslt processor.

  • 0

I’ve got an xml file. It is meant for being transformed by xslt processor. The specific template is ready, however it use some information from two additional xml files. All information is used to produce the proper output.

It works fine when I open the main xml file with my browser. The problem is: the result is just a fragment of website, it is an HTML element ready for being appended as a child. That is why I want to transform the xml with the xslt processor within a JavaScript function. Unfortunatelly, the result is half-way done. All what don’t need the additional information from these two xml files imported by xpath expression is transformed well. The rest is shortly speaking absent.

JavaScript:

var xhttp = new XMLHttpRequest()
var xsltProcessor = new XSLTProcessor()
xhttp.open("GET", "contentTemplate.xsl", false)
xhttp.send()
xsltProcessor.importStylesheet(xhttp.responseXML)

function buildElement(what) {
var xmlDoc = document.implementation.createDocument("", "root", null)
xmlDoc.documentElement.appendChild(xmlDoc.createElement(what))

var resultDocumentFragment = xsltProcessor.transformToFragment(xmlDoc, document)
return resultDocumentFragment
}

xslt:

there is lots of stuff, I paste just the xslt with xpath expression

<xsl:variable name="extInfo" select="document('tagAvailableToAdd.xml')/root"/>
<xsl:for-each select="$extInfo/tag">
 <option>
  <xsl:attribute name="value"><xsl:value-of select="tagName"/></xsl:attribute>
  <xsl:value-of select="description"/>
 </option>
</xsl:for-each>

and that is just absent. Just like no information was delivered.

EDIT:

it works in firefox, doesn’t in chrome. I need to improve it. Actually, I don’t know how.

  • 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-05-18T02:21:30+00:00Added an answer on May 18, 2026 at 2:21 am

    I thought I had solved the problem, however an issue in firefox has occured.

    Nevertheless, I concern chrome my native browser, that is why i’m glad I made it work in this program. That is the change I implemented in JavaScript:

    function talkToServer(address, synch, func) {
    func = typeof(func) != 'undefined' ? func : null
    xhttp.open(method, address, synch)
    xhttp.onreadystatechange = func
    xhttp.send()
    }
    
    function getXPath(query) {
    return document.evaluate(query, xhttp.responseXML, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null)
    }
    
    function buildElement(what) {
    var xmlDoc = document.implementation.createDocument("", "root", null)
    xmlDoc.documentElement.appendChild(xmlDoc.createElement(what))
    
    switch(what) {
    case "windowElement":
    talkToServer("tagAvailableToAdd.xml", false)
    var additionalInfo = getXPath("/root/tag")
    var aim = xmlDoc.documentElement.getElementsByTagName("windowElement")[0]
    for(i=0;i<additionalInfo.snapshotLength;i++)
        aim.appendChild(additionalInfo.snapshotItem(i).cloneNode(true))
    
    talkToServer("cssTemplates.xml", false)
    additionalInfo = getXPath("/root/*")
    aim.appendChild(xmlDoc.createElement("css"));
    aim = aim.getElementsByTagName("css")[0]
    for(i=0;i<additionalInfo.snapshotLength;i++)
        aim.appendChild(additionalInfo.snapshotItem(i).cloneNode(true))
    break;
    }
    var resultDocumentFragment = xsltProcessor.transformToFragment(xmlDoc, document)
    return resultDocumentFragment
    }
    

    in xslt now I have all information in , so there is no need to import any external info.

    main function is buildElement. I’m sure everybody can see what it does. It’a aim is to provide sth I can “paste” to HTML document.

    In chrome it works. In firefox says: Node cannot be used in a document other than the one in which it was created” code: “4, and points at return statement in getXPath function. I don’t know how ti fix it, but who cares, it is just firefox (I know it’s stupid). In IE it suck, because xhttp is XHttpRequest object, but I believe, that when I provide ActiveX it should give what I want.

    If you feel you can help me with the firefix issue, write a comment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.