Currently I use:
To link XSL to XML.
If my xml was here: www.externald
You can't achieve this with "pure" xml+xslt(*). Some external code will need to identify the xml and the xslt which should transform it.
Since you seem to be transforming XML, I'm going to guess you're doing this in the webbrowser.
You can do this using javascript, as demonstrated on w3schools. However, cross-domain restrictions still apply if you're doing javascript-based requests (i.e. AJAX/XHR): if the originating server doesn't set the appropriate CORS headers to allow cross-domain javascript access, you'll need to proxy that xml request via your own server.
(*): Mad's answer uses entity references to cleverly embed external xml in a containing document. It's definitely worth a try, but be aware that this kind of entity-based inclusion has been used in several information-disclosure leaks, which is why it's often not enabled in the xml parser (in particular, this shouldn't be able to subvert CORS in a browser). You'll just have to try it in your situation.
If you're trying to run the XSLT inside .NET, you can easily use the XslCompiledTransform class in .NET to achieve this.
If you're trying to run this on e.g. the command line, there's a bunch of tools you can use to apply a XSLT file to a given XML file - typically however one that's on your local harddisk.
See e.g. Oleg Tkachenko's web site for info on NXSLT and this other XSLT tools, or see this CodeProject article for a Windows shell extension to apply a XSLT to a given XML file (on your local harddisk).
Hope this helps a bit.
Marc
You could write a local xml file as wrapper:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="XSL.xsl" ?>
<wrapper Source="http://www.externaldomain.com/rss.xml"/>
And extend your stylesheet so that it understands the wrapper:
<xsl:template match="wrapper">
<xsl:apply-templates select="document(./@Source)"/>
</xsl:template>
I haven't tested it with XML files over http but it works with local XML files that I don't want to change to include a xml-stylesheet processing instruction. It works mit Firefox, Opera and IE (7, I haven't tried other versions)
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>
One solution: Get the external XML into an XMLDocument object and then insert a node that contains include statement of xsl. Include xsl can be taken from http://adityabajaj.com/weblog/include-xsl-in-x-ml/.