<xsl:stylesheet version = "1.0"
|
<xsl:template match="XSL ÆÐÅÏ"
name = "ÅÛÇø´ À̸§"
mode = "¸ðµå À̸§"> |
<xsl:apply-templates select = "XSL ÆÐÅÏ" mode = "¸ðµå À̸§" /> |
<xsl:template
match="header"> <¼Ò°³> <xsl:apply-templates /> </¼Ò°³> </xsl:template> |
<xsl:template
match="header"> <¼Ò°³> <xsl:apply-templates select="name" /> </¼Ò°³> </xsl:template> |
<xsl:value-of select = "XSL ÆÐÅÏ" /> |
Source Tree |
| ||||||||||||
Result Tree
| |||||||||||||
|
<xsl:output method="xml|html|text" encoding="ÄÚµå" indent="yes|no" /> |
<xsl:element name = "¿ä¼Ò¸í" namespace
= "URI" |
<xsl:template
match="¼º"> <family>°¡¹®</family> <xsl:element name="family">°¡¹®</xsl:element> <xsl:element name="{.}">¼º¾¾</xsl:element> </xsl:template> <xsl:template match="Ȩ"> <xsl:element name="home" namespace="{.}">ȨÆäÀÌÁö</xsl:element> <xsl:element name="mm:home" namespace="{.}">ȨÆäÀÌÁö</xsl:element> </xsl:template> |
<family>°¡¹®</family> <family>°¡¹®</family> <È«>¼º¾¾</È«> <home xmlns="http://mm.sm.ac.kr> ȨÆäÀÌÁö</home> <mm:home xmlns="http://mm.sm.ac.kr> ȨÆäÀÌÁö</home> |
<xsl:attribute name =
"¼Ó¼º¸í" namespace = "URI" > |
<body> <xsl:attribute name="type"> <xsl:value-of select="³»¿ë/@Á¾·ù"/> </xsl:attribute> <p><xsl:value-of select="³»¿ë"/></p> </body> |
<body
type="HTML"> <p>¾È³çÇϼ¼¿ä? ... </p> </body> |
<xsl:attribute-set
name="body-attr"> <xsl:attribute name="type">html</xsl:attribute> <xsl:attribute name="lang">kr</xsl:attribute> </xsl:attribute-set > ... <xsl:element name="body" use-attribute-sets="body-attr"> <p><xsl:value-of select="³»¿ë"/></p> </xsl:element> |
<body
type="html" lang="kr"> <p>¾È³çÇϼ¼¿ä? ... </p> </body> |
<?xml
version="1.0" encoding="EUC-KR"?> <¸í´Ü> <¼º¸í ¼º="È«" À̸§="±æµ¿"/> <¼º¸í ¼º="±è" À̸§="³²ÀÏ"/> </¸í´Ü> |
<?xml
version="1.0" encoding="EUC-KR"?> <people> <name> <¼º>È«<¼º> <À̸§>±æµ¿</À̸§> </name> <name> <¼º>±è<¼º> <À̸§>³²ÀÏ</À̸§> </name> </people> |
(Left ¡æ Right)
<xsl:template
match="/">
<people> <xsl:apply-templates select="¸í´Ü/¼º¸í" /> </people> </xsl:template> <xsl:template match="¼º¸í"> <name> <xsl:apply-templates select="@*" /> <!-- ¸ðµç ¼Ó¼º¿¡ ´ëÇÏ¿© Àû¿ë --> </name> </xsl:template> <xsl:template match="@*"> <xsl:element name="{local-name()}"> <xsl:value-of select="." /> </xsl:element> </xsl:template> |
(Left ¡ç Right)
<xsl:template
match="/">
<¸í´Ü> <xsl:apply-templates /> </¸í´Ü> </xsl:template> <xsl:template match="//name"> <xsl:element name="¼º¸í" use-attribute-sets="name-attr"> </xsl:template> <xsl:attribute-set name="name-attr"> <xsl:attribute name="¼º"> <xsl:value-of select="¼º" /> </xsl:attribute> <xsl:attribute name="À̸§"> <xsl:value-of select="À̸§" /> </xsl:attribute> </xsl:attribute-set > |
<xsl:text> ...
</xsl:text> |
<xsl:comment>ÁÖ¼®¹®
»ý¼º</xsl:comment> |
<!-- ÁÖ¼®¹® »ý¼º
--> <?xml-stylesheet type="text/xsl" href="ex01.xsl" ?> <?xml:stylesheet href="ex.css" type="text/css" ?> |
<xsl:copy>
... </xsl:copy>
<!-- ÇöÀçÀÇ ³ëµå¸¸ º¹»ç
--> |
<xsl:template
match="name"> 1) <xsl:copy-of select="."/> 2) <xsl:copy-of select="¼º"/> 3) <xsl:copy /> 4) <xsl:copy> <xsl:value-of select="."/> </xsl:copy> </xsl:template> |
1)
<name><¼º>È«</¼º><À̸§>±æµ¿</À̸§></name>
2) <¼º>È«</¼º> 3) <name/> 4) <name>È«±æµ¿</name> |
|
·çÆ® ¹× ¸ðµç ¿ä¼Ò¿¡
´ëÇØ ÅÛÇø´ ¸í±â°¡ ¾øÀ¸¸é ÀڽĿ¡ ´ëÇÏ¿© ÅÛÇø´ Àû¿ëÀ» ¹Ýº¹ |
|
³ëµåÀÇ ÅؽºÆ®³ª
¼Ó¼ºÀ» ±×´ë·Î °á°úÆ®¸®¿¡ Ãß°¡ |
|
PI ¹× Comment´Â »ý·« |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="*"> <xsl:apply-templates /> </xsl:template> <xsl:template match="text() | @*"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="/"> . . . |
ÁÖ¼Ò
¹Ýº¹ ÅؽºÆ®³ëµå ·çÆ®¿¡¼ ½ÃÀÛ |
½Ç½À ¿¹Á¦ (ÁÖ¼Ò·Ï/º¯È¯½ºÅ¸ÀÏ)
ÅÂ±×¸í º¯È¯ 1 (output, element) | ÅÂ±×¸í º¯È¯ 2 (PI, attribute) |
<xsl:output
method="xml" indent="yes"/> |
<xsl:template
match="/"> |
Ç¥·Î º¯È¯ 2 (apply-templates »ç¿ë ÁÖÀÇ) | Ç¥ º¯È¯ ( for-each ¹Ýº¹¹® »ç¿ë) |
<xsl:template
match="/"> |
<xsl:template
match="/"> |
<xsl:if test = "Á¶°Ç¹®" > ... </xsl:if> |
<xsl:template
match="product"> »óÇ°¸í : <xsl:value-of select="name" /> <xsl:if test="price[number(.) > 100000]"> - °í±Þ »óÇ°</xsl:if> </xsl:template> |
<xsl:choose> |
<xsl:template
match="product"> »óÇ°¸í : <xsl:value-of select="name" />- °¡°Ý¼öÁØ : <xsl:choose> <xsl:when test="price[number(.) > 200000]">- °í±Þ</xsl:when> <xsl:when test="price[number(.) > 50000]">- Áß°£</xsl:when> <xsl:otherwise>- Àú°¡</xsl:otherwise> </xsl:choose> </xsl:template> |
<xsl:for-each select = "XSL ÆÐÅÏ" > ... </xsl:for-each> |
<¸í´Ü> <¼º¸í ¼º="È«" À̸§="±æµ¿"/> <¼º¸í ¼º="±è" À̸§="³²ÀÏ"/> </¸í´Ü> |
<people> <name><¼º>È«<¼º><À̸§>±æµ¿</À̸§></name> <name><¼º>±è<¼º><À̸§>³²ÀÏ</À̸§></name> </people> |
<xsl:template match="/"> <people> <xsl:apply-templates select="¸í´Ü/¼º¸í" /> </people> </xsl:template> <xsl:template match="¼º¸í"> <name> <xsl:apply-templates select="@*" /> </name> </xsl:template> <xsl:template match="@*"> <xsl:element name="{local-name()}"> <xsl:value-of select="." /> </xsl:element> </xsl:template> |
¿ÞÂÊ º¯È¯ ÆÄÀÏÀ»
for-each ÀÌ¿ëÇÏ¿© ¼öÁ¤ <xsl:template match="/"> <people> <xsl:for-each select="¸í´Ü/¼º¸í" /> <name> <xsl:apply-templates select="@*" /> </name> </xsl:for-each> </people> </xsl:template> <xsl:template match="@*"> <xsl:element name="{local-name()}"> <xsl:value-of select="." /> </xsl:element> </xsl:template> |
1) °¡°ÝÇ¥½Ã Á¦´ë·Î Çϱâ ($**.**, ****¿ø), °¹¼ö ¹× ÇÕ°è ±¸Çϱâ
2) Ç¥ ¸¸µé±â (Àç°í ¾ø´Â µµ¼ Á¦¿Ü)
3) ¸ñ·ÏÀ¸·Î ¸¸µé±â
µµ¼ ¸ñ·Ï 2 (if test ÀÌ¿ë, ¹®Á¦Á¡ ?) | µµ¼ ¸ñ·Ï 3 (choose ÀÌ¿ë, count, sum) |
<xsl:template
match="/"> <HTML><BODY> <H3>µµ¼ ¸ñ·Ï</H3> <font size="2"> <xsl:apply-templates /> </font> </BODY></HTML> </xsl:template> <xsl:template match="book"> <B><I>Á¦¸ñ : </I></B> <xsl:value-of select="title"/><br/> <B><I>ÀúÀÚ : </I></B> <xsl:value-of select="author"/><br/> <B><I>°¡°Ý : </I></B> <xsl:if test="price[@currency='usd']"> $</xsl:if> <xsl:value-of select="price"/>¿ø<br/> <B><I>Àç°í : </I></B> <xsl:value-of select="@InStock"/>±Ç<P/> </xsl:template> |
<xsl:template
match="/"> ... <H3>µµ¼ ¸ñ·Ï : <xsl:value-of select="count(/list/book)"/>Á¾ (ÃÑ<xsl:value-of select= "sum(/list/book/@InStock)"/>±Ç) ... </xsl:template> <xsl:template match="book"> <B><I>Á¦¸ñ : </I></B> ... <B><I>ÀúÀÚ : </I></B> ... <B><I>°¡°Ý : </I></B> <xsl:choose> <xsl:when test="price[@currency='usd']"> $<xsl:value-of select="price"/><br/> </xsl:when> <xsl:otherwise> <xsl:value-of select="price"/>¿ø<br/> </xsl:otherwise> </xsl:choose> <B><I>Àç°í : </I></B> ... </xsl:template> |
µµ¼ Àç°í ¸ñ·ÏÇ¥ 4 (¹®Á¦Á¡ ?) | µµ¼ Àç°í ¸ñ·ÏÇ¥ 5 (for-each ÀÌ¿ë) |
<xsl:template match="/">
... <table border="1"> <tr><th>Á¦¸ñ</th><th>ÀúÀÚ</th><th>... </tr> <xsl:apply-templates /> </table> ... </xsl:template> <xsl:template match="book[@InStock!='0']"> <tr> <td> <xsl:value-of select="title/text()"/></td> <td><xsl:value-of select="author"/></td> <td><xsl:choose><xsl:when>$ ... <xsl:otherwise>¿ø</xsl:choose></td> <td><xsl:value-of select="@InStock"/>±Ç</td></tr> </xsl:template> |
<xsl:template match="/">
... <table border="1"> <tr><th>Á¦¸ñ</th><th>ÀúÀÚ</th><th>... </tr> <xsl:apply-templates /> ... </xsl:template> <xsl:template match="list"> <xsl:for-each select="book[@InStock!='0']"> <tr> <td><xsl:value-of select="title/text()"/></td> <td><xsl:value-of select="author"/></td> <td><xsl:choose>$ ... ¿ø</xsl:choose></td> <td><xsl:value-of select="@InStock"/>±Ç</td></tr> </xsl:for-each> </xsl:template> |
<xsl:apply-templates select="ÆÐÅÏ"
mode="¸ðµå"/> . . . <xsl:template match="ÆÐÅÏ" mode="¸ðµå1">...A...</xsl:template> <xsl:template match="ÆÐÅÏ" mode="¸ðµå2">...B...</xsl:template> <xsl:template match="ÆÐÅÏ">...O...</xsl:template> |
<xsl:call-template
name="À̸§"/> . . . <xsl:template name="À̸§">...A...</xsl:template> . . . <xsl:call-template select="ÆÐÅÏ" name="À̸§"/> . . . <xsl:template match="ÆÐÅÏ" name="À̸§">...B...</xsl:template> |
³í¹® ¸ñÂ÷ 2 : ¸µÅ© ³×ÀÓ, generate-id() |
³í¹® ¸ñÂ÷ 3 : call-template |
<xsl:template
match="/"> <html> <body> <H2><xsl:value-of select="/article/title"/> (<xsl:value-of select="/article/date"/>) ©</H2> <P><B>Table of Contents</B></P> <ol> <xsl:for-each select="article/section/title"> <LI><A> <xsl:attribute name="HREF"> #<xsl:value-of select="generate-id()"/> </xsl:attribute> <xsl:value-of select="."/></A></LI> </xsl:for-each> </ol> <xsl:apply-templates /> </body> </html> </xsl:template> <xsl:template match="section/title"> <P><I><B> <A><xsl:attribute name="NAME"> <xsl:value-of select="generate-id()"/> </xsl:attribute></A> <xsl:apply-templates/> </B></I></P> </xsl:template> <xsl:template match="article/title | abstract | data | keywords"/> |
<xsl:template
match="/"> <html> <head> <title><xsl:call-template name="title"/></title> </head> <body> <h2><xsl:call-template name="title"/></h2> <xsl:apply-templates /> <p><u><center> <xsl:call-template name="title"/> </center></u></p> </body> </html> </xsl:template> <xsl:template name="title"> <xsl:value-of select="chapter/title"/> ( <xsl:value-of select="chapter/date"/> ) © </xsl:template> <xsl:template match="section/title"> <P><I><B> <xsl:apply-templates/> </B></I></P> </xsl:template> <xsl:template match="article/title | abstract | data | keywords"/> |
<xsl:variable name="À̸§"> ...
</xsl:variable> . . . . . . "$À̸§" |
<xsl:param name="À̸§"> ...
</xsl:param> . . . . . . "$À̸§" . . . <xsl:with-param name="À̸§"> ... </xsl:with-param> |
<xsl:apply-imports> <xsl:decimal-format> <xsl:fallback> <xsl:import> <xsl:include> |
<xsl:key> <xsl:message> <xsl:namespace-alias> <xsl:preserve-space> <xsl:strip-space> |