ex01.xml | ex01.xsl |
<?xml version="1.0" encoding="EUC-KR" ?> <?xml-stylesheet type="text/xsl" href="ex01.xsl"?> <memo> <header> <date> 2002. 4. 15. </date> <name lang="kr"> È«±æµ¿ </name> </header> <body> <p> XML ±Ô°ÝÁ¦Á¤À» À§ÇÑ È¸ÀÇ°¡ ÀÖÀ¸´Ï Âü¼®ÇÏ¿© Áֽñ⠹ٶø´Ï´Ù. </p> <p> ȸÀÇ Âü¼® ¿©ºÎ¸¦ ¾Ë·Á Áֽñ⠹ٶø´Ï´Ù. </p> </body> </memo> |
<?xml version="1.0" encoding="EUC-KR" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999 /XSL/Transform"> <xsl:template match="/"> <HTML> <BODY> <H2>1st Example (H2 ÁöÁ¤)</H2> ´Ü¼øÈ÷ º¯È¯ (ÁöÁ¤ ¾øÀ½) </BODY> </HTML> </xsl:template> </xsl:stylesheet> |
ex02.xml | ex02.xsl |
<?xml version="1.0"
encoding="EUC-KR"?> <¹æ¸í·Ï> <¼º¸í> <¼º>È«</¼º> <À̸§> ±æµ¿ </À̸§> </¼º¸í> <ÀüÀÚ¿ìÆí>gildong@email.com</ÀüÀÚ¿ìÆí> <³»¿ë Á¾·ù="HTML">¾È³çÇϼ¼¿ä? ¸¸³ª¼ ¹Ý°©½À´Ï´Ù. </³»¿ë> </¹æ¸í·Ï> |
<?xml version="1.0" encoding="EUC-KR" ?> <xsl:stylesheet version="1.0" xmlns:xsl= "http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/"> <memo> <header> <xsl:apply-templates select="¹æ¸í·Ï/¼º¸í" /> </header> <body> <p><xsl:value-of select="¹æ¸í·Ï/³»¿ë"/></p> </body> </memo> </xsl:template> <xsl:template match="¼º¸í"> <name> <xsl:value-of select="¼º" /> <xsl:value-of select="À̸§" /> </name> </xsl:template> </xsl:stylesheet> |
C:>MSXML
ex02.xml ex02.xsl out02.xml
<memo>
<header> <name>È« ±æµ¿</name> </header> <body> <p>¾È³çÇϼ¼¿ä? ¸¸³ª¼ ¹Ý°©½À´Ï´Ù.</p> </body> </memo> |
ÆÐÅÏ ±âÈ£ | ÀÇ¹Ì | »ç¿ë ¿¹ |
¿ä¼Ò¸í | child node | memo/header/date , header/date, body/p |
/ | root | / (root), /memo , /memo/header/name |
. | current node | . (current), ./memo/body (= memo/body) |
.. | parent node | ../memo/body |
* | any node | * (any), memo/header/* , body/* |
// | descendent | // (all), //name, memo/header//, memo//p |
@¼Ó¼º¸í | attribute | @lang, name/@lang |
ÆÐÅÏ | ÀÇ¹Ì | »ç¿ë ¿¹ |
[k] | k-th element | body/p[1], memo//p[3] |
elmt[child] | child¶ó´Â ÀÚ½ÄÀ» °¡Áø ¸ðµç elmt ¿ä¼Ò | header[date] |
elmt[child=val] | child¶ó´Â ÀÚ½ÄÀÌ valÀ̶ó´Â °ªÀ» °¡Áö´Â ¸ðµç elmt ¿ä¼Ò | memo[header/name='È«±æµ¿'] |
elmt[@attr] | attrÀ̶ó´Â ¼Ó¼ºÀ» °¡Áø ¸ðµç elmt ¿ä¼Ò | name[@lang] |
elmt[@attr=val] | attrÀ̶ó´Â ÀÚ½ÄÀÌ valÀ̶ó´Â °ªÀ» °¡Áö´Â ¸ðµç elmt ¿ä¼Ò | name[@lang='kr'] |
¿¬»êÀÚ | ÆÐÅÏ | »ç¿ë ¿¹ |
and, or, not | [ch1 and ch2], [ch1 or ch2], [not ch1] | //header[name or
date],
//header[not(date)] |
=, != | [child = val], [child != val] | name[@lang='kr'] header[name!='È«±æµ¿'] |
< <= > >= | [child < val], [child <= val], [child > val], [child >= val], | order[price < 300,000], order[price >= 300,000] |
<xsl:value-of select="/"/> <xsl:value-of select="."/> <xsl:value-of select="/memo/header"/> <xsl:value-of select="./memo/header/date"/> <xsl:value-of select="header/name"/> <xsl:value-of select="memo/body"/> <xsl:value-of select="memo/body/*"/> <xsl:value-of select="//header//name"/> <xsl:value-of select="//name/@lang"/> <xsl:value-of select="//name[@lang='kr']"/> <xsl:value-of select="memo/body/p[1]"/> <xsl:value-of select="memo//p[2]"/> |