[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Can someone please explain:<xsl:template match="*" />
alex chang wrote: > > Can someone please explain: > > <xsl:template match="*" /> You're lucky to be looking at such well documented code. :-) > <!-- The template with match="*" below is a fail-safe. Which means it's error-handling for a condition which is not expected to arise. Commenting it out therefore has no effect on a well-formed example, but makes the code slightly less robust. > If at any point we > get to a node in the XML tree that doesn't match any of our template match > statements, we replace that node with blank space. --> Reads pretty clearly to me. XSL template matching basically goes from the most specific to the least. There are some subtle rules to it, but in practice you usually get it right. match="/top/node" will take precedence over match="node", and for that matter match="*" (everything not already matched) All the example you are looking at is saying is that if there is unexpected content in your source XML (Say one day you add <AUTHOR>alex</AUTHOR>) the stylesheet will explicitly ignore it instead of displaying it in plaintext (which is the default behavior). This means that your author tag will not appear in the output _until_ you get around to handling it with a <xsl:template match="AUTHOR"><i><xsl:value-of select="."/></xsl:template> or similar. Of course if you're confused enough to be using the old Microsoft 'XSL' parser, this template is odd because the default behaviour of MSXML was originally to ignore everything anyway. Folk who wanted proper easy behaviour had to add the opposite to that fail-safe: <xsl:template match="*"><xsl:value-of select="."/></xsl:template> ... to get results. Easy really. And please Alex, use subject lines when posting to several thousand busy people. .dan. :=====================:====================: : Dan Morrison : The Web Limited : : http://here.is/dan : http://web.co.nz : : dman@xxxxxxxx : danm@xxxxxxxxx : : 04 384 1472 : 04 495 8250 : : 025 207 1140 : : :.....................:....................: : If ignorance is bliss, why aren't more people happy? :.........................................: XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|