XSLT <xsl:apply-templates> ÔªËØ
¶¨ÒåºÍÓ÷¨
<xsl:apply-templates> ÔªËØ¿ÉÏòµ±Ç°ÔªËØ»òµ±Ç°ÔªËصÄ×ÓÔªËØÓ¦ÓÃÄ£°å¡£
Èç¹ûÎÒÃÇÏò <xsl:apply-templates> ÔªËØÌí¼Ó select ÊôÐÔ£¬ÄÇôËü½ö»á´¦ÀíÆ¥Åä¸ÃÊôÐÔµÄÖµµÄ×ÓÔªËØ¡£ÎÒÃÇ¿ÉʹÓà select ÊôÐÔÀ´¹æ¶¨´¦Àí×Ó½éµãµÄ˳Ðò¡£
Óï·¨
<xsl:apply-templates select="expression" mode="name"> <!-- Content:(xsl:sort|xsl:with-param)* --> </xsl:apply-templates>
ÊôÐÔ
ÊôÐÔ | Öµ | ÃèÊö |
---|---|---|
select | ±í´ïʽ | ¿ÉÑ¡¡£¹æ¶¨Òª´¦ÀíµÄ½Úµã¡£ÐǺÅѡȡÕû¸ö½Úµã¼¯¡£Èç¹ûÊ¡ÂÔ¸ÃÊôÐÔ£¬Ôò½«Ñ¡È¡µ±Ç°½ÚµãµÄËùÓÐ×ӽڵ㡣 |
mode | Ãû³Æ | ¿ÉÑ¡¡£Èç¹û´æÔÚΪÏàÍ¬ÔªËØ¶¨ÒåµÄ¶à¸ö´¦Àí·½·¨£¬ÄÇôÓà mode ¿ÉÒÔÇø·ÖËüÃÇ¡£ |
ʵÀý
Àý×Ó 1
Óà h1 ÔªËØ°üΧÎĵµÖÐÿ¸ö title ÔªËØ£º
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="title">
<h1><xsl:apply-templates/>
</h1>
</xsl:template>
</xsl:stylesheet>
Àý×Ó 2
Óà h1 ÔªËØ°üΧÎĵµÖÐËùÓÐÊôÓÚ message µÄ×ÓÔªËØµÄ title ÔªËØ£º
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="message">
<h1><xsl:apply-templates select="title"/>
</h1>
</xsl:template>
</xsl:stylesheet>
Àý×Ó 3
Óà h1 ÔªËØ°üΧÎĵµÖÐ mode ÊôÐÔÉèÖÃΪ "big" µÄ message ËùÓÐ×ӽڵ㣺
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="message">
<h1><xsl:apply-templates select="*" mode="big"/>
</h1>
</xsl:template>
</xsl:stylesheet>