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 9103877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:44:03+00:00 2026-06-17T01:44:03+00:00

I’m writing a Chrome extension which should apply XSLT transform to certain XML documents

  • 0

I’m writing a Chrome extension which should apply XSLT transform to certain XML documents on the fly. Just for testing I use the following XML and XSL files:

XML:

<?xml version="1.0" encoding="utf-8" ?>
<WebServiceMessage>
 <status>timeout</status>
 <message>Nameserver%2520not%2520registered.</message>
 <stepName>Finish</stepName>
 <stepNumber>11</stepNumber>
 <maxStepNumber>11</maxStepNumber>
 <percent>100</percent>
 <session>2fc0f139b88a800151e5f21b9d747919</session>
</WebServiceMessage>

XSL:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><head></head>
    <body>
      <xsl:apply-templates/>
    </body>
    </html>
  </xsl:template>
  <xsl:template match="*">
    <xsl:for-each select="*">
      <p><b><xsl:value-of select ="name(.)"/></b>:
      <span><xsl:attribute name="id"><xsl:value-of select ="name(.)"/></xsl:attribute><xsl:value-of select="."/></span></p>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

The tranfromation works normally if it’s linked inside a test XML file itself, that is via:

<?xml-stylesheet type="text/xsl" href="message.xsl"?>

The extension should inject the same xsl link into XML-files.

manifest.json:

{
  "permissions": ["tabs", "<all_urls>"],
  "content_scripts":
  [
    {
      "matches": ["<all_urls>"],
      "js" : ["contentscript.js"]
    }
  ],
  "web_accessible_resources":
  [
    "message.xsl"
  ],
  "manifest_version": 2
}

contentscript.js:

(function()
{
  if(document.xmlVersion != null)
  {
     var e = document.createProcessingInstruction(
               "xml-stylesheet",
               "type='text/xsl' href='" + chrome.extension.getURL("message.xsl") + "'");
     document.insertBefore(e, document.firstChild);
  }
})();

The problem

Chrome outputs the following error into console:

Unsafe attempt to load URL chrome-extension://ladfinoepkgipbeooknnklpakoknohjh/message.xsl from frame with URL http://localhost/out.xml. Domains, protocols and ports must match.

How to fix this? I saw some reports on the Internet related to similar errors, which seems like a bug in Chrome.

I placed the xsl-file on the web-server as well, and changed styleheet link to the web-server. Still the same error:

Unsafe attempt to load URL http://localhost/message.xsl from frame with URL http://localhost/out.xml. Domains, protocols and ports must match.

Apparently domains, protocols, and ports do match.

  • 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-17T01:44:04+00:00Added an answer on June 17, 2026 at 1:44 am

    Here is a workaround I’m currently using:

    function loadXMLtext(url)
    {
      xhttp = new XMLHttpRequest();
      xhttp.open("GET", url, false);
      xhttp.send();
      if(xhttp.responseXML == undefined) throw "XHR failed for " + url;
      return xhttp.responseXML;
    }
    
    function transformxml()
    {
      var xml = loadXMLtext(document.location.href);
      var xsl = loadXMLtext(chrome.extension.getURL("message.xsl"));
    
      var xsltPrs = new XSLTProcessor();
      xsltPrs.importStylesheet(xsl);
    
      var result = xsltPrs.transformToFragment(xml, document);
    
      var xmlsrv = new XMLSerializer();
      var plaintext = xmlsrv.serializeToString(result);
      document.documentElement.innerHTML = plaintext;
    }
    
    transformxml();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.