Alex Rivera | Logout

Apply XSL to External XML

Asked 2009-09-27T15:11:11.200
13

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?

Edit
Report

1 Answer

2

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)

answered 2010-01-20T11:52:44.427

Your Answer