The way to apply an XSLT stylesheet like msg.xsl to the document msg.xml in a browser is by using a processing instruction. A processing instruction (PI) allows you to include instructions for an application in an XML document.
You can see a processing instruction in a slightly altered version of msg.xml, which I call msg-pi.xml:
<?xml-stylesheet href="msg.xsl" type="text/xsl"?>
<msg/>
The XML stylesheet PI should always come before the first element in the document (the document element msg in msg-pi.xml). The purpose of this PI is similar to one of the purposes of the link tag in HTML, that is, to associate a stylesheet with the document. Save msg-pi.xml in a text file with the other files. If you open msg-pi.xml in one of the browsers I mentioned, the built-in XSLT processor in the browser will write the string Found it! on the browser's canvas or rendering space.
No comments:
Post a Comment