Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply XSL to External XML

Tags:

xml

xslt

Currently I use:

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

To link XSL to XML.

If my xml was here: www.externaldomain.com/rss.xml (Outside of my domain) how can i get the XSL linked to the XML?

Can i point the XSL to a File or Link?

like image 234
CLiown Avatar asked Sep 27 '09 15:09

CLiown


1 Answers

You can create a local XML file that includes the XML content of the remote XML file through an entity reference.

The example below will give you the content of the remote XML file inside of a wrapper document element.

Then you can include a stylesheet processing instruction on your local XML file.

However, since the local file has a wrapper document element, you might need to point to a "wrapper XSLT" that uses xsl:import to import the original XSL.xsl and apply-templates starting with the content inside the wrapper element.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wrapper [
<!ENTITY content SYSTEM "http://stackoverflow.com/feeds">
]>
<?xml-stylesheet type="text/xsl" href="XSL.xsl" ?>
<wrapper>
    &content;
</wrapper>
like image 60
Mads Hansen Avatar answered Oct 15 '22 16:10

Mads Hansen