xsl defining in xml

2019-03-04 19:51发布

问题:

My first few lines in movies.xml are as follows :

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="movies_style.xsl"?>
<movies 
    xmlns="http://www.w3schools.com" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.w3schools.com file:///B:/USC/Academic/DBMS/HWS/no3/movie_sch.xsd">

and first few lines in movies_style.xsl are as follows :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format">

Problem is if remove schema file linking from movies.xml file and keep tag only as <movies> then proper styled table is shown as output else nothing is displayed in browser and error is displayed in console as:

"Unsafe attempt to load URL file:///B:/USC/Academic/DBMS/HWS/no3/movies_style.xsl from frame with URL file:///B:/USC/Academic/DBMS/HWS/no3/movies.xml. Domains, protocols and ports must match."

Looks like some namespace mistake. Can anyone point out exactly what ?

回答1:

The problem appears to be that the schema file is not web accessible. It's on a B: drive accessed using the file: but the XML and XSL are probably access using http: and the browser (assuming you are viewing with a browser) won't load using file: due to security concerns. Try relocating the schema file so it can be loaded using HTTP.



回答2:

had given targetnamespace as w3schools.org. that shouldn't be there. that was the problem.