XML – Domains, protocols and ports do not match

Error:

I was trying to load an xml stylesheet called xsl and I kept getting the following errors:

on Chrome: Unsafe attempt to load URL chrome-extension: .xsl from frame with URL test.xml. Domains, protocols and ports must match.

on Firefox: Error loading stylesheet: An unknown error has occurred (805303f4)

Cause:

Each browser has some security policies which do not allow access to different domains, protocols or ports are seen above.

Solution:

Allow access using cross domain policy. There are two ways of doing so:

Create an xml file named crossdomain.xml and paste the following code:

<?xml version=”1.0″?>
<cross-domain-policy>
<allow-access-from domain=”*” />
</cross-domain-policy>

Open your current XML file and right after the root element paste the following:

<allow-access-from domain=”*” />

The second option should look like:

<?xml-stylesheet href=”styling.xsl” type=”text/xsl”?>

<Books>

<allow-access-from domain=”*” />

<timestamp>2013-06-13T19:51:08</timestamp>

<Book>

<author> Ben </author>

</Book>

<Book>

<author> Ben </author>

</Book>

</Books>

Note: 

<allow-access-from domain=”*” />

using the * means you will be giving access to all domains which is not suggested. If you have a specific domain specifiy as follows:

<allow-access-from domain=”www.mydomain.com” />

2 thoughts on “XML – Domains, protocols and ports do not match

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s