ȨÆäÀÌÁö ²À´ë±â·Î

XSLT Quickly Ã¥ Á¤¸®

XSLT Quickly?

XSLT¸¦ °øºÎÇϸç Âü°íÇÑ Ã¥Àε¥ »ó´çÈ÷ ÁÁ´Ù. ¿¹Á¦·Î¹è¿ì´Â XSLT.
Ã¥ Ç¥Áö

½ÇÀü¿¡¼­ ¹Ù·Î »ç¿ëÇÒ¸¸ÇÑ ÁÁÀº ¿¹Á¦µéÀÌ °¡µæÇÏ´Ù. ÀÌÃ¥À» º¸¸é¼­, ³»¿ëÀ» ÅؽºÆ®ÆÄÀÏ·Î Á¤¸®Çؼ­ XSLÀÛ¾÷ÀÌ ÇÊ¿äÇÒ¶§ ¹Ù·Î¹Ù·Î °Ë»öÇؼ­ Àû¿ëÇÏ´Ï XSL ÀÛ¼º È¿À²ÀÌ ÁÁ¾ÆÁ³´Ù. °Ô´Ù°¡ ¸¹Àº ÁÁÀº ÆÁµéÀÌ °°ÀÌ µé¾î ÀÖ´Ù.

XSLT Quickly ¿ä¾à

¡Ú XSL ±âº» Çì´õ¿Í ǪÅÍ

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
...³»¿ë...
</xsl:stylesheet>

¡Ú p.40 ¼Ó¼º ¹Ù²Ù±â

<wine price="1" year="1997">Carneros</wine>
       ¡é
<wine vintage="1997">Carneros</wine>

<xsl:template match="wine">
  <wine vintage="{@year}">
    <xsl:apply-template/>
  </wine>
</xsl:template>

¼Ó¼ºÀ̳ª ¿ä¼Ò¸¦ »èÁ¦ÇÒ¶§´Â ±×³É ¾ð±ÞÀ» ȸÇÇÇÏ¸é µÉ»Ó... @¹®ÀÚ´Â ÁöÁ¤ÇÑ À̸§À» °¡Áö´Â ¼Ó¼ºÀÇ °ªÀ» ÀǹÌÇÑ´Ù.

{} Áß°ýÈ£´Â XSLT°¡ ±× ¾ÈÀÇ ³»¿ëÀ» ±ÛÀÚ ±×´ë·Î °¡Á®¿ÀÁö ¾Ê°í ¼ö½ÄÀ¸·Î¼­ ¿¬»ê ÇÑ µÚ¿¡ °¡Á®¿Àµµ·Ï ÁöÁ¤ÇÏ´Â °ÍÀÌ´Ù. {2 + 2}¶ó°í Çϸé 4°¡ µé¾î°¡°Ô µÈ´Ù.

¡Ú p.41 ¼Ó¼º°ú ¿ä¼Ò°£ÀÇ º¯È¯

<wine grape="Chardonnay">
  <product>Carneros</product>
  <year>1997</year>
  <price>10.99</price>
</wine>
       ¡é
<wine vintage="1997">
  <product>Carneros</product>
  <category>Chardonnay</category>
  <price>10.99</price>
</wine>

<xsl:template match="wine">
  <wine vintage="{year}">
    <product><xsl:apply-templates select="product"/></product>
    <category><xsl:value-of select="@grape"/></category>
    <price><xsl:apply-templates select="price"/></price>
  </wine>
</xsl:template>

¡Ú p.42 ¼Ó¼º°ª¿¡ µû¶ó ¿ä¼Ò ¼±ÅÃÇϱâ

¾î¶² ¿ä¼Ò°¡ ƯÁ¤ ¼Ó¼ºÀ» °¡Áú¶§¸¸ ¼±ÅÃÇϱâ

<xsl:template match="wine[@grape='Cabernet']">
  <xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>

¡Ú p.50 XPathÀÇ ·ÎÄÉÀÌ¼Ç ½ºÅÜ

child::wine[last()]
Ãà ::³ëµåÅ×½ºÆ®[ÇÁ·¹µðÄÉÀÌÆ®]

Axis ::NodeTest[Predicate]
Çʼö ·ÎÄÉÀÌ¼Ç ½ºÅÜÀº ³ëµå»ÓÀÌ´Ù. ÃàÀº º¸Åë »ý·«µÇ´Â child·Î °£Áֵǰí ÇÁ·¹µðÄÉÀÌÆ®´Â Á¶°ÇÀ» Á༭ Á¶°Ç¿¡ ¸Â´Â ³ëµå¸¸À» Ãë»ç ¼±ÅÃÇϴµ¥¿¡ »ç¿ëÇÑ´Ù. ÇÁ·¹µðÄÉÀÌÆ®´Â ¹®¼­ÀÇ ¸ÇÀ§ºÎÅÍ µûÁö´Â °ÍÀÌ ¾Æ´Ï¶ó ÇöÀç ÄÁÅؽºÆ® ³ëµå ÀڽŰú °¡±î¿îÂÊÀÌ 1 °¡Àå ¸ÕÂÊÀÌ last()°¡ µÈ´Ù.

¡Ú p.50 ÄÁÅؽºÆ®(Context) ³ëµå¶õ?

ÇöÀç ó¸®ÁßÀÎ ³ëµå¸¦ ÀǹÌÇÑ´Ù.

¡Ú p.51 Ãà(Axis)?

Ãà ÇÑÁ¤ÀÚ´Â ¼±ÅÃµÉ ³ëµå¿Í ÄÁÅؽºÆ® ³ëµå »çÀÌÀÇ À§Ä¡ °ü°è¸¦ ÁöÁ¤ÇÑ´Ù.
Á¾·ù :

child, descendant, parent, ancester, following-sibling, preceding-sibling,
following, preceding, attribute, name-space, self, descendant-or-self, ancestor-or-self

¡Ú p.52 ºÎ¸ð ³ëµåÀÇ ¼Ó¼ºÀ» Ç¥½ÃÇϱâ

<wine grape="Cabernet">
  <year>1998</year>
  <prices>
    <list>13.99</list>
    <discounted>11.99</discounted>
  </prices>
</wine>

ÇöÀç ÄÁÅؽºÆ® ³ëµå°¡ prices À϶§, ¿©±â¿¡ ºÎ¸ð³ëµå(<wine>)ÀÇ ¼Ó¼ºÀ» Ç¥½ÃÇÏ·Á¸é,

<xsl:template match="prices">
  parent element's grape:
  <xsl:value-of select="parent::wine/attribute::grape"/>
</xsl:template>

parent¿Í attribute´Â °¢°¢ .. ¿Í @ ·Î Ãà¾àÇؼ­ Ç¥ÇöÇÒ ¼ö ÀÖ´Ù.

<xsl:template match="prices">
  parent element's grape:
  <xsl:value-of select="../@grape"/>
</xsl:template>

¡Ú p.53 child ÃàÀÇ Ãà¾àÇü

XPath¿¡¼­ ÃàÀÌ »ý·«µÇ¸é ¹«Á¶°Ç child ÃàÀÇ »ý·«À¸·Î °£ÁÖÇÑ´Ù. <wine>À» ó¸®ÇÏ´Â µµÁß ±×ÀÇ ÀڽijëµåÀÎ yearÀÇ °ªÀ» °¡Á®¿À·Á¸é,

<xsl:template match="wine">
  <wine vintage="{child::year}">
</xsl:template>

ȤÀº, Ãà ÇÑÁ¤ÀÚ°¡ »ý·«µÇ¸é ¹«Á¶°Ç child·Î °£ÁÖÇϹǷÎ,

<xsl:template match="wine">
  <wine vintage="{year}">
</xsl:template>

{year}ºÎºÐÀ» <xsl:value-of select="year"/>·Î ´ë½ÅÇÒ ¼ö ´Â ¾ø´Ù.

¡Ú p.53 ¼ö½ÄÀÇ Ã³¸®

¼ö½ÄÀ» °è»êÇϰųª ¾î¶² ³ëµåÀÇ °ªÀ» <xsl:value-of/>°¡ ¾Æ´Ñ ¹æ¹ýÀ¸·Î ¾òÀ¸·Á¸é {}»çÀÌ¿¡ ³ÖÀ¸¸é µÈ´Ù. {}³»ºÎ¿¡ ÀÖ´Â °ªÀ» °è»êµÈµÚ¿¡ ÀԷµȴÙ.

¡Ú p.55 ancestor Ãà

<A>
  <B>
    <C/>
  </B>
</A>

°¡ ÀÖÀ»¶§ <C>ÀÇ ancestor´Â <A>, <B>¸¦ ÀǹÌÇÑ´Ù. ancester:A ¿Í °°Àº Çü½ÄÀ¸·Î ÁöÁ¤ÇÏ¸é µÈ´Ù.

¡Ú p.56 ancestor-or-self Ãà

<A>
  <B>
    <C/>
  </B>
</A>

°¡ ÀÖÀ»¶§ <C>ÀÇ ancestor-or-self´Â <A>,<B>,<C>ÀÌ´Ù.

¡Ú p.56 ÀÚ±â ÀڽŠȤÀº ÀÚ±âÀÇ ºÎ¸ð°¡ °¡Áø ƯÁ¤ ¼Ó¼ºÀÇ °ªÀ» Á¶°ÇÀ¸·Î ÁÙ¶§,

<xsl:template matching="waring">
  <xsl:if test="ancester-or-self::*[@xml:lang][1]/@xml:lang='en'">
    <p>Warning!</b><xsl:apply-templates/></p>
  </xsl:if>
</xsl:template>

ÀÌ °æ¿ì, ¾Æ·¡ºÎÅÍ À§·Î °Ë»öÇسª°£´Ù. <C>ÀÇ À§Ä¡¿¡¼­ ¸ÕÀú <B>¸¦ °Ë»çÇÏ°í ±× ´ÙÀ½¿¡ <A>¸¦ °Ë»çÇϹǷΠ¸¸¾à xml:lang ¼Ó¼ºÀÌ B ¿Í A¿¡ ÀÖÀ» °æ¿ì xml:lang[1]Àº BÀ§Ä¡ÀÇ ¼Ó¼ºÀÌ °Ë»çµÇ°Ô µÈ´Ù. xml:lang[last]´Â AÀ§Ä¡ÀÇ ¼Ó¼ºÀ̵ȴÙ.

¡Ú p.58 preceding-sibling / following-sibling

ÀÚ±â¿Í µ¿ÀÏÇÑ ºÎ¸ð ¹Ø¿¡ ÀÖ´Â ³ëµåµé Áß, preceding-siblingÀºÀڱ⺸´Ù À§¿¡ ¼ÓÇÑ °ÍµéÀÌ°í following-siblingÀº Àڱ⺸´Ù ¾Æ·¡¿¡ ¼ÓÇÑ °ÍµéÀÌ´Ù.

<story>
  <chapter>
    <title>A</title>Contents A</chapter>
  <chapter>
    <title>B</title>Contents B</chapter>
  <chapter>
    <title>C</title>Contents C</chapter>
</story>

¡é

chapter
Prev:
Next: B

chapter
Prev: A
Next: C

chapter
Prev: B
Next:

À§¿Í °°ÀÌ ÇÏ·Á¸é...

<xsl:template match="chapter">
  <h3>chapter</h3>Prev: <xsl:value-of select="preceding-sibling::chapter[1]/title"/><br/>
    Next: <xsl:value-of select="following-sibling::chapter/title"/>
    <xsl:value-of select="./text()"/><br/>
</xsl:template>

preceding-siblingÀÌ ÇÁ·¹µðÄÉÀÌÆ®¸¦ °è»êÇÒ ¶§´Â ÀÚ±â¿Í °¡±î¿î ÂÊ, Áï Àڱ⠹ٷΠÀ§¸¦ 1·Î ÇÏ°í, ÀÚ±â¿Í °¡Àå ¸Õ ¸Ç À§ÀÇ °ÍÀ» last()·Î ÇÑ´Ù.

¡Ú p.61 preceding°ú following

preceding ÃàÀº ¹®¼­ÀÇ Ã³À½ºÎÅÍ ÄÁÅؽºÆ® ³ëµå ¹Ù·Î ÀÌÀü±îÁö, followingÀº ÄÁÅؽºÆ® ³ëµå ¹Ù·Î ´ÙÀ½ºÎÅÍ ¹®¼­ÀÇ ³¡±îÁöÀÇ ¸ðµç ³ëµå¸¦ ÀǹÌÇÑ´Ù. ÇüÁ¦, ºÎ¸ð ÇÒ°Í ¾øÀÌ ´Ù Æ÷ÇÔÇÑ´Ù. ÇÁ·¹µðÄÉÀÌÆ®´Â ÀڽŰú °¡±î¿îÂÊÀÌ 1ÀÌ´Ù.

<A>
  <B>
    <C><TITLE>1</TITLE><T/></C>
    <C><TITLE>2</TITLE><D><T/></D></C>
    <C><TITLE>3</TITLE><C>
  <B>
<A>

ù¹ø° <T>´Â <C>ÀÇ ÀÚ½ÄÀÌ°í µÎ¹ø° <T>´Â <D>ÀÇ ÀÚ½ÄÀÌ´Ù. ¿©±â¼­ 1°ú 3À» ¾òÀ¸·Á¸é,

<xsl:template match="test">
<xsl:value-of select="preceding::C[1]/TITLE"/>
<xsl:value-of select="following::C/TITLE"/>
</xsl:template>

¡Ú p.65 descendant¿Í descendant-or-self

descendant´Â ÄÁÅؽºÆ® ³ëµåÀÇ Àڽĵé°ú ±× ÀڽĵéÀÇ ÀÚ½Äµé µî, ÄÁÅؽºÆ® ³ëµåÀÇ ¸ðµç ÀڽĵéÀ» ÀǹÌÇÑ´Ù. descendant-or-self´Â ¸» ±×´ë·Î ÀÚ½ÅÀ» Æ÷ÇÔÇÑ ÀÚ¼Õµé.

<xsl:for-each select="descendant::figure">
  <xsl:value-of select="title"/>
</xsl:for-each>

ÀÌ°ÍÀº Àڱ⠾Ʒ¡¿¡ ÀÖ´Â ¸ðµç figure ³ëµå¿¡¼­ title ¿ä¼ÒÀÇ °ªÀ» °¡Á®¿Â´Ù.

<xsl:for-each select="descendant-or-self::*/@author">
<xsl:value-of select="."/>
</xsl:for-each>

ÀÚ±â ÀÚ½ÅÀ» Æ÷ÇÔÇÏ¿© ±× ÀÚ½Ä ¸ðµÎ¸¦ °Ë»çÇÏ¿© author ¼Ó¼ºÀÇ °ªÀ» Ãâ·ÂÇÑ´Ù.

¡Ú p.69 descendent-or-self ÀÇ Ãà¾à

¡Ú p.70 self

self ´Â ÄÁÅؽºÆ® ³ëµå ±× ÀÚ½ÅÀÌ´Ù. ÀÌ°ÍÀÇ Ãà¾àÀº . À¸·Î self:node()¸¦ ÀǹÌÇÑ´Ù.

¡Ú p.70 namespace

ÀÌ°ÍÀº ±âº» xml ³×ÀÓ½ºÆäÀ̽º¿Í ÄÁÅؽºÆ® ³ëµåÀÇ ¹üÀ§ ¾È¿¡ ÀÖ´Â ¸ðµç ³×ÀÓ½ºÆäÀ̽º·Î ±¸¼ºµÈ´Ù. (Ç¥ÁØÀº xml ³×ÀÓ½ºÆäÀ̽º¸¦ Æ÷ÇÔÇØ¾ß ÇÏÁö¸¸ ±×·¸Áö ¾ÊÀº °Íµµ ÀÖ´Ù.)

<xsl:template match="test">
  <xsl:for-each select="namespace::*">
    <xsl:value-of select="name()"/>
    <xsl:text>
    </xsl:text>
  </xsl:for-each>

¡Ú p.72 ³ëµå Å×½ºÆ®(Node test)

* Àº ¸ðµç ¿ä¼Ò(Element) ³ëµå¸¦ ÀǹÌÇÑ´Ù. node() ´Â Á¾·ù¿¡ »ó°ü¾ø´Â ¸ðµç ³ëµå¸¦ ÀǹÌÇÑ´Ù. ÀÌ°ÍÀº ÁÖ¼®À̳ª PIµîµµ Æ÷ÇÔÇÑ´Ù.

<xsl:for-each selec="node()">
  <xsl:value-of select="." />
</xsl:for-each>

¡Ú ÇÁ·¹µðÄÉÀÌÆ®(Predicate)

ÇÁ·¹µðÄÉÀÌÆ®´Â Âü/°ÅÁþÀÇ °ª¸¸ °¡Áø´Ù.

¡Ú p.77 ¼ÕÀÚ ³ëµåÀÇ Á¶°Ç¿¡ µû¶ó ÀÚ½Ä ³ëµåÀÇ °ªÃâ·Â

<xsl:template match="winelist">
Wines:needing their "discount" value set;
  <xsl:for-each select="wine/prices/discounted[not(text())]">
    <xsl:value-of select="../../year"/><xsl:text> </xsl:text>
    <xsl:value-of select="../../winery"/><xsl:text </xsl:text>
  </xsl:for-each>
</xsl:template>

¡Ú p.83 µ¿ÀûÀ¸·Î ÅÂ±× »ý¼º

<xsl:element name="ode">³»¿ë</xsl:element>
ÀÌ°ÍÀº <ode>³»¿ë</ode>¸¦ »ý¼ºÇÑ´Ù.
ÀÌ°ÍÀ» ÀÌ¿ëÇØ Á¤ÇØÁöÁö ¾ÊÀº µ¿Àû ÅÂ±× »ý¼ºÀÌ °¡´ÉÇØÁø´Ù. ´ÙÀ½Àº poemÀÇ type ¼Ó¼º¿¡ µû¶ó µ¿ÀûÀ¸·Î ű׸¦ »ý¼ºÇÑ´Ù.

<xsl:template match="poem">
  <xsl:element name="{@type}">
    <author>John Milton</author>
    <year><xsl:value-of select="@year"/></year>
  </xsl:element>
</xsl:template>

¡Ú p.84 <xsl:apply-templates>´Â ÇöÀç ³ëµåÀÇ ÀÚ½Ä ³ëµå¸¸À» ´Ù·é´Ù.

ÀÌ°ÍÀº ÀÚ½Ä ³ëµåµéÀÌ <xsl:template>À» °®°í ÀÖÁö ¾ÊÀ» °æ¿ì ±× ³ëµåÀÇ °ªÀ» ÃëÇؼ­ Ãß°¡ÇØÁØ´Ù. ÀÌ°ÍÀ» ³»Àå ÅÛÇø´ ·êÀ̶ó°í ÇÑ´Ù.

¡Ú p.86 ºÎ¸ð, ÀÚ½Ä, ÇüÁ¦ÀÇ °ª ¾ò±â, ³ëµåÀÇ À̸§¾ò±â

<xsl:template match="list">
~~~~~ Start of list element's template ~~~~~
1. List price (current node) : {<xsl:apply-templates/>}
2. Parent element (price) : {<xsl:value-of select=".."/>
3. Grandparent element contents : {<xsl:value-of select="../.."/>}
4. Attribute of grandparent : {<xsl:value-of select="../../@grape"/>}
5. Sibling node {<xsl:value-of select="../discounted"/>}
6. "Uncle" node {<xsl:value-of select="../../product"/>}
7. Parent node's name: {<xsl:value-of select="name(..)"/>}
8. Grandparent node's name: {<xsl:value-of select="name(../..)"/>}
~~~~~ End of list element's template ~~~~~
</xsl:template>

¡Ú p.89 Á¤ÇØÁöÁö ¾ÊÀº ÀÚ±â ÇüÁ¦ ÂüÁ¶

<xsl:template match="item[3]">
~~~ Start of item element's template ~~~
1. This node : {<xsl:apply-templates/>}
2. First node : {<xsl:value-of select="../item[1]/>}
3. Last node : {<xsl:value-of select="../item[last()]"/>}
4. Preceding node : {<xsl:value-of select="preceding-sibling::item[1]"/>
5. Next node : {<xsl:value-of select="following-sibling::item[1]"/>}
6. flavor attriute value of first node : {<xsl:value-of select="../item[1]/@flavor"/>}
~~~ End of item element's template ~~~

xsl:value-of´Â ±âº»ÀûÀ¸·Î ¼±ÅÃµÈ ³ëµåµé Áß Ã¹¹ø° °Í¸¸ ¹ÝȯÇÑ´Ù.

¡Ú p.92 ¿ä¼Ò¸¦ ¼Ó¼ºÀ¸·Î º¯È¯Çϱâ

" " ³»¿¡ <xsl:value-of>¸¦ ¾µ ¼ö ¾ø´Ù. ±× ´ë½Å ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÑ´Ù.

<xsl:template match="wine">
  <wine variental="{@grape}" brand="{winery}" year="{../year}"/>
</xsl:template>

¡Ú p.96 ¿ä¼Ò¸¦ º¹»çÇÏ¸ç ¼Ó¼º Ãß°¡

<xsl:copy>°¡ ´Üµ¶À¸·Î ¾²À̸é ÄÁÅؽºÆ® ³ëµåÀÇ ¿ä¼Ò À̸§¸¸ º¹»çµÉ »ÓÀÌ´Ù. Áï, ű׸¸ º¹»çµÇ°í ű×ÀÇ ³»¿ëÀº º¹»çµÇÁö ¾Ê´Â´Ù.
´ÙÀ½Àº, <xsl:copy>¿Í ´Ù¸¥ ¸í·ÉÀ¸·Î ¼Ó¼º°ú ³»¿ëÀ» º¹»çÇÏ´Â °ÍÀÌ´Ù.

<xsl:copy>
  <xsl:attribute name="date"> <!-- ÀÌ°ÍÀÌ ¼Ó¼ºÀ» Ãß°¡ÇØ Áִ °ÍÀÌ´Ù. -->
    <xsl:value-of select="@date"/>
  </xsl:attribute>
  <xsl:apply-templates/> <!-- ³»¿ëº¹»ç -->
</xsl:copy>

¡Ú p.96 ÄÁÅؽºÆ® ³ëµå¸¦ Àڽİú ¼Ó¼º±îÁö ¿ÏÀüÇÏ°Ô ±×´ë·Î º¹»çÇϱâ

Àڽİú ¿ä¼Ò´Â ¹°·Ð PI¿Í ÁÖ¼®, ³×ÀÓ½ºÆäÀ̽º µî±îÁö º¹»çÇÑ´Ù.

<xsl:template match="wine">
  <xsl:copy-of select="."/>
</xsl:template>

¡Ú p.100 ³ëµåÀÇ °³¼ö ¼¼±â

count() ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ´Ù.

<xsl:template match="employees">
  A. Number of employees:
  <xsl:value-of select="count(employee)"/>
  B. Number of officers:
  <xsl:value-of select="count(employee[@officer='yes'])"/> <!-- 'yes' ÀÛÀº µû¿ÈÇ¥! -->
  C. Number of employees without 'officer' attribute set:
  <xsl:value-of select="count(employee[not(@officer)])"/>
  D. Number of comments in 'employees' element:
  <xsl:value-of select="count(//comment())"/> <!-- ¸ðµç ÁÖ¼®ÀÇ °³¼ö -->
</xsl:template>

¡Ú p.103 apply-templates ¿¡¼­ ó¸®ÇÒ ³ëµå¸¦ Á÷Á¢ ÁöÁ¤Çϱâ

<xsl:template match="customer">
  <client>
    <xsl:apply-templates select="lastName"/>
    <xsl:apply-templates select="phone"/>
  </client>
</xsl:template>

¸¸¾à ¿©±â¼­ ±×³É <xsl:apply-templates/>¸¦ ÇÑ´Ù¸é ¸ðµç customerÀÇ ÀÚ½Ä ³ëµåµéÀÇ ³»¿ëÀÌ ¿©±â¿¡ »ðÀ﵃ °ÍÀÌ´Ù. ¿©±â¼­´Â lastName°ú phone¿¡¸¸ ÅÛÇø´À» Àû¿ëÇÏ¿© µÎ ÀÚ½Ä ³ëµåµéÀÇ °ª¸¸ °¡Á®¿Àµµ·Ï ÇÑ´Ù.

¡Ú p.104 µ¿ÀÏÇÑ ³»¿ë(text())¸¦ °¡Áø ¿ä¼Ò Á¦°Å

<sample>
  <line lid="u1">hello</line>
  <line color="red" lid="u2">hello</line>
  <line color="blue" lid="u3">hello</line>
  <line lid="u4">hello there</line>
  <line color="blue" lid="u5">hello there</line>
  <line color="blue" lid="u6">hello</line>
</sample>

¡é

<sample>
  <line lid="u1">hello</line>
  <line lid="u4">hello there</line>
</sample>

¼Ó¼ºÀº ¾Æ¹« °ü°è ¾øÀÌ ³ëµåÀÇ ³»¿ëÀÌ µ¿ÀÏÇÑ °ÍÀ» Á¦°ÅÇÏ·Á¸é

<xsl:template match="line">
  <xsl:if test="not(. = preceding::line)">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/> <!-- ¼Ó¼º°ú ³ëµåÀÇ ³»¿ë º¹»ç -->
    </xsl:copy>
  </xsl:if>
</xsl:template>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

¡Ú p.105 µ¿ÀÏÇÑ ¼Ó¼ºÀ» °¡Áø ¿ä¼Ò Á¦°Å

<xsl:template match="line">
  <xsl:if test="not(@color = preceding::line/@color)">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:if>
</xsl:template>

not(@color = preceding::line/@color) ´Â ÄÁÅؽºÆ® ³ëµåÀÇ color ¼Ó¼ºÀÇ °ª°ú ÇöÀç ³ëµå À§ÂÊ¿¡ Á¸ÀçÇÏ´Â line ¿ä¼ÒÀÇ color ¼Ó¼ºÀ» ºñ±³ÇÏ¿© ´Ù¸£¸é ÂüÀ» ¸®ÅÏÇÑ´Ù.

¡Ú p.106 ¿ä¼Ò¿Í ¼Ó¼ºÀ» µ¿½Ã¿¡ ºñ±³Çϱâ

<xsl:template match="line">
  <xsl:variable name="contents" select="."/>
  <xsl:variable name="colorVal" select="@color"/>
  <xsl:if test = "not(preceding::line[(. = $contents) and (@color = $colorVal)])">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:if>
</xsl:template>

not(preceding::line(. = $contents) and (@color = $colorVal)]) ¿¡¼­ .Àº preceding::line ³ëµå¸¦ ÀǹÌÇÏ°í, @color ´Â preceding::lineÀÇ color ¼Ó¼ºÀ» ÀǹÌÇÑ´Ù.

¡Ú p.109 ÀÌ ³ëµå´Â ºñ¾î Àִ°¡? (text()°¡ ¾ø´Â°¡?)

<xsl:template match="sample">
  <xsl:choose>
    <xsl:when test="normalize-space(.)">
      Sample element <xsl:value-of select="@eid"/> isn't empty.
    </xsl:when>
    <xsl:otherwise>
      Sample element <xsl:value-of select="@eid"/> is empty.
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

normalize-space(node)´Â ³ëµå ÁýÇÕÀ» ¹®ÀÚ¿­·Î ÀüȯÇÑ ÈÄ ¿©·¯ °ø¹éÀ» Çϳª·Î ¹Ù²Ù°í, ¹®ÀÚ¿­ ¾ÕµÚÀÇ °ø¹éÀ» Àß¶ó³½ µÚ ¹®ÀÚ°¡ ³²¾Æ ÀÖÀ¸¸é true ±×·¸Áö ¾ÊÀ¸¸é false ÀÌ´Ù.

¡Ú p.116 ƯÁ¤ ÀÚ½ÄÀ» °®°í ÀÖ´Â ¿ä¼ÒÀÇ ÅÛÇø´

<xsl:output method="text"/>
<xsl:strip-space elements="*"/>

<xsl:template match="setc2[figure]"> <!-- figure¶ó´Â ÀڽĠ³ëµå°¡ Àִ°¡? -->
  <xsl:value-of select="title"/>
  [<xsl:apply-templates/>]
</xsl:template>

¡Ú p.117 ³ëµå ³»¿ë¿¡ ƯÁ¤ÇÑ ¹®ÀÚ¿­À» Æ÷ÇÔÇÑ ¿ä¼Ò´Â?

<xsl:template match="para[contains(.,'the')]"> <!-- contains()ÀÇ . À» ÁÖÀÇÇ϶ó. -->
  ** This para has "the" in it: ***
  <xsl:apply-templates/>
</xsl:template>

¹®ÀÚ¿­ÀÌ ÀÚ½Ä ³ëµå¿¡ Æ÷ÇԵǾî À־ ¸¶Âù°¡Áö ÀÌ´Ù.

¡Ú p.121 »õ·Î¿î ¿ä¼Ò¿Í ±× ¿ä¼ÒÀÇ ¼Ó¼º Ãß°¡Çϱâ

<xsl:template match="verse">
  <xsl:element name="line"> <!-- <line> Å±װ¡ »ý¼ºµÈ´Ù. -->
    <xsl:attribute name="status">done</xsl:attribute> <!-- <line status="done">
    <xsl:attribute name="hue"> 
      <xsl:value-of select="@color"/>
    </xsl:attribute> <!-- <line status="done" hue="@colorÀÇ °ª">
    <xsl:attribute name="number">
      <xsl:value-of select="amount"/>
    </xsl:attribute>
    <xsl:attribute name="sourceElement">
      <xsl:text>src</xsl:text><xsl:value-of select="generate-id()"/>
    </xsl:attribute>
  </xsl:element>
</xsl:template>

ÃÖÁ¾ »ý¼º ű״ <line status="done" hue="@color" number="5" sourceElement="srcb2a"/>

¡Ú p.124 ¼Ó¼ºÀÇ À̸§°ú °ª ¾ò±â

<para color="blue" flavor="mint" author="bd">Here is a paragraph.</para>

¡é

Color : blue
attribute name: color
attribute value: blue
attribute name: flavor
attribute value: mint
attribute name: author
attribute value: bd

À§¿Í °°ÀÌ ¼Ó¼ºÀÇ À̸§°ú °ªÀ» ¾òÀ¸·Á¸é,

<xsl:template match="para">

Color : <xsl:value-of select="@color"/>

<!-- list the attribute names and values. -->
<xsl:for-each select="@*">
attribute name: <xsl:value-of select="name()"/>
attribute value: <xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

¡Ú p.126 ¼Ó¼ºÀÇ Á¸Àç ¿©ºÎ. ¼Ó¼ºÀÌ Æ¯Á¤ÇÑ °ªÀ» °¡Áö°í Àִ°¡?

<para color="blue" flavor="mint" author="jm">Here is a paragraph.</para>

¡é

There is a flavor attribute
Athor equals "jm"
<xsl:template match="para">
  <xsl:if test="@flavor">There is a flavor attribute</xsl:if>
  <xsl:if test="@font">There is a font attribute</xsl:if>
  <xsl:if test="@author = 'jm'">Author equals "jm"</xsl:if>
</xsl:template>

¡Ú p.127 ¼Ó¼º ±×·ì(Attribute set) »ç¿ëÇϱâ

¼Ó¼º ±×·ìÀ» ¸¸µé°í ¾î¶² ¿ä¼Ò¿¡ ÇѲ¨¹ø¿¡ Ãß°¡½ÃÄÑ ÁÙ ¼ö ÀÖ´Ù.

<xsl:attribute-set name="lineAttrs">
  <xsl:attribute name="status">done</xsl:attribute>
  <xsl:attribute name="hue">
    <xsl:value-of select="@color"/> <!-- µðÆúÆ®°ª. µðÆúÆ® °ªÀº ¹«½ÃµÉ ¼ö ÀÖ´Ù. -->
  </xsl:attribute>
  <xsl:attribute name="number">
    <xsl:value-of select="amount"/>
  </xsl:attribute>
  <xsl:attribute name="sourceElement">
    <xsl:text>src</xsl:text><xsl:value-of select="generate-id()"/>
  </xsl:attribute>
</xsl:attribute-set>

<xsl:template match="verse">
  <xsl:element name="line" use-attribute-sets="lineAttrs">
    <xsl:attribute name="author">BD</xsl:attribute> <!-- µðÆúÆ® °ªÀ» ¹«½ÃÇÔ -->
    <xsl:attribute name="hue">NO COLOR</xsl:attribute> <!-- µðÆúÆ® °ªÀ» ¹«½ÃÇÔ -->
    </xsl:apply-templates>
  </xsl:element>
</xsl:template>

¡Ú p.129 HTML ÁÖ¼® Ãâ·ÂÇϱâ

<xsl:template match="poem">
<html>
  <xsl:comment>Created By FabAutoDocGen release 3</xsl:comment>
  <xsl:apply-template>
</html> </xsl:template>

¡Ú p.131 HTML ÁÖ¼® »çÀÌ¿¡ ³ëµåÀÇ °ª Ãâ·ÂÇϱâ

<xsl:template match="documentation">
  <xsl:comment><xsl:apply-templates/></xsl:comment>
</xsl:template>

¡Ú p.131 XMLÆÄÀÏ ÀÚüÀÇ ÁÖ¼® ÀÌ¿ëÇϱâ

<xsl:template match="comment()">
  <xsl:comment><xsl:value-of select="."/></xsl:comment>
</xsl:template>

¡Ú p.136 °á°ú Æ®¸®¿¡ ¿£Æ¼Æ¼ ·¹ÆÛ·±½º »ðÀÔ

<!DOCTYPE stylesheet [
ENTITY ntilde "n"
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="test">
  <testOut>
    The Spanish word for "Spain" is "Espana".
    <xsl:apply-templates/>
  </testOut>
</xsl:template> </xsl:stylesheet>

½ºÅ¸ÀϽÃÆ®¿¡ ±âº»ÀûÀ¸·Î ¹Ì¸® ¼±¾ðµÈ ´Ù¼¸°³ÀÇ ¿£Æ¼Æ¼(lt, gt, apos, quot, amp)¿ÜÀÇ ´Ù¸¥ ¿£Æ¼Æ¼¸¦ ÂüÁ¶ÇÏ°íÀÚ ÇÑ´Ù¸é, ±×°ÍµéÀ» DOCTYPE ¼±¾ðºÎ¿¡ Á÷Á¢ ¼±¾ðÇØ ÁÖ¾î¾ß ÇÑ´Ù.

¡Ú p.138 ¿£Æ¼Æ¼ ·¹ÆÛ·±½º ÀÚü¸¦ »ðÀÔÈ÷±â

<!DOCTYPE stylesheet [
ENTITY ntilde
"<xsl:text disable-output-escaping='yes'>n</xsl:text>"
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output doctype-system="testOut.dtd"/>
  <xsl:template match="test">
    <testOut>
      The Spanishword for "Spain" is "Espana"
      <xsl:apply-templates/>
    </testOut>
  </xsl:template>
</xsl:stylesheet>

Espana °¡ ÀÌ ¸ð¾ç ±×´ë·Î Ãâ·ÂµÈ´Ù.

¡Ú p.142 Namespace ÁöÁ¤

"xsl"À» XSLT ¿ä¼ÒÀÓÀ» ³ªÅ¸³»´Â Á¢µÎ»ç·Î »ç¿ëÇÏ´Â °ÍÀº ´ÜÁö °ü·ÊÀÏ »ÓÀÌ´Ù. ´Ù¸¥ °ÍÀ» ÁöÁ¤Çصµ µÈ´Ù.

<harpo:stylesheet
  xmlns:harpo="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
<harpo:output method="xml" omit-xml-declaration="yes"/>

<harpo:template match="xdata">
  <heading>xdata</heading><harpo:text>
  </harpo:text>
  <text><harpo:apply-templates/></text>
</harpo:template> </harpo:stylesheet>

¡Ú p.147 XML¹®¼­¸¦ XSLT·Î º¯È¯ÇÏ·Á¸é

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xslAlt="http://www.snee.com/xml/dummy"
  version="1.0">

<!-- xslAlt¸¦ xsl·Î ¹Ù²ã Ãâ·ÂÇ϶ó -->
<xsl:namespace-alias stylesheet-prefix="xslAlt" result-prefix="xsl"/>
<xsl:template match="elementHandler">
  <!-- ¾Æ·¡´Â <xsl:template match="@element°ª"> À¸·Î Ãâ·ÂµÈ´Ù. -->
  <xslAlt:template match="{@element}">
    <xsl:apply-templates/>
  </xslAlt::template>
</xsl:template>

<xsl:template match="elementContents">
  <xslAlt:apply-templates/>
</xsl:template>
<xsl:template match="ssheet">
  <xslAlt:stylesheet version="1.0">
    <xsl:apply-templates/>
  </xslAlt:stylesheet>
</xsl:template>
<!-- Just copy any other elements, attributes, etc. -->
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template> </xsl:stylesheet>

¡Ú p.156 Çؼ® ºÒ°¡´ÉÇÑ ¿£Æ¼Æ¼(JPG ÆÄÀϵî)ÀÇ URIÃß°¡

<xsl:template match="picture">
  <img src=http://img.yahoo.co.kr/blank.gif>
</xsl:template>

picfile ÀÌ XMLÆÄÀÏ¿¡ ´ÙÀ½°ú °°ÀÌ ÁöÁ¤µÇ¾î ÀÖ´Ù¸é

ENTITY ceres SYSTEM "../pics/cerespic.jpg" NDATA JPEG
»ý·«..
<picture picfile="ceres"/>

¡Ú p.159 PI Ãâ·Â

<xsl:template match="article">
  <xsl:processing-instruction name="xml-stylesheet">
    <xsl:text>href="headlines.css" type="text/css"</xsl:text>
  </xsl:processing-instruction>
  <html>
    <xsl:apply-templates/>
  </html>
</xsl:template>

À§ÀÇ °á°ú´Â

<?xml-stylesheet href="headlines.css" type="text/css"?>

xsl:processing-instructionÀÌ Æ®¸®ÀÇ ÃÖ»óÀ§¿¡ À§Ä¡Çؼ­´Â ¾ÈµÈ´Ù. ¸¸¾à ±×°ÍÀÌ xsl:stylesheet ¿ä¼ÒÀÇ ÀÚ½ÄÀ̶ó¸é, XSLT ÇÁ·Î¼¼¼­´Â ±×°ÍÀ» ¹«½ÃÇÑ´Ù.

¡Ú p.161 ¿øº» Æ®¸®¿¡¼­ PI Àаí ÀÌ¿ëÇϱâ

<xsl:template match="processing-instruction()">
  <xsl:copy/>
<xsl:template>

Á»´õ ¼¼¹ÐÇÏ°Ô ÀÌ¿ëÇϱâ

<?xml-stylesheet href="headlines.css" type="text/css"?>
<?smellPlugIn scent="newCar" duration="12secs"?>

¿Í °°Àº PI°¡ ÀÖÀ» ¶§..

<xsl:template match="processing-instruction('xml-stylesheet')">
  ¡¡¡¡¡¡¡¡¡¡¡¡<stylesheet><xsl:value-of select="."/></stylesheet>
</xsl:template>

<xsl:template match="processing-instruction('smellPlugIn')">
  <smellData><xsl:value-of select="."/></smellData>
</xsl:template>

¡Ú p.164 <xsl:if> ÃÑÁ¤¸®

<xsl:template match="poem">
--- Start of "if" tests. ---
<xsl:if test="@author='jm'"> <!-- author ¼Ó¼ºÀÌ 'jm'Àΰ¡? -->
  1. The poem's author is jm.
</xsl:if>

<xsl:if test="@author"> <!-- author ¼Ó¼ºÀÌ Á¸ÀçÇϴ°¡? -->
  2. The poem has an author attribute
</xsl:if>

<xsl:if test="verse"> <!-- verse ÀڽĠ¿ä¼Ò¸¦ °¡Áö°í Àִ°¡? -->
  4. The poem has at least one verse child element.
</xsl:if>

<xsl:if test="count(verse) > 3"> <!-- Å©´Ù. ±ÄÀÌ > ¸¦ »ç¿ë¾ÈÇصµ µÊ -->
  6. The poem has more than 3 verse child elements.
</xsl:if>

<xsl:if test="count(verse) < 3"> <!-- ÀÛ´Ù. <¸¦ »ç¿ëÇϸ頾ȵÇ! -->
  6. The poem has less than 3 verse child elements.
</xsl:if>

<!-- or Á¶°ÇÁÖ±â -->
<xsl:if test="(@author = 'bd') or (@year='1667')>
  8. Either the author is "bd" or the year is "1667".
</xsl:if>

<!-- Áßø if -->
<xsl:if test="@year < '1850'">
  9a. The poem is old.
  
  <xsl:if test="@year < '1700'">
    9b. The poem is very old.
  </xsl:if>
  
  <xsl:if test="@year < '1500'">
    9c. The poem is very, very old.
  </xsl:if>
</xsl:if> </xsl:template>

¡Ú p.169 <xsl:choose> ÃÑÁ¤¸®

<xsl:template match="poem">
<xsl:choose>
  <xsl:when test="@year < 1638">
  The poem is one of Milton's earlier works.
  </xsl:when>

  <xsl:when test="@year < 1650">
  The poem is from Milton's middle period.
  </xsl:when>

  <xsl:when test="@year < 1668">
  The poem is one of Milton's later works.
  </xsl:when>

  <xsl:when test="@year < 1675">
  The poem is one of Milton's last works.
  </xsl:when>

  <xsl:otherwise>
  The poem was written after Milton's death
  </xsl:otherwise>
</xsl:choose> </xsl:template>

xsl:choose ´Â ÃÖÃÊ·Î Á¶°ÇÀ» ¸¸Á·½ÃŲ ºÎºÐ¸¸ ½ÇÇàÇÏ°í ³¡³­´Ù.

¡Ú p.170 ¾ðÁ¦ Áß°ýÈ£{}¸¦ »ç¿ëÇϴ°¡?

<xsl:template match="/">
<test>
  <xsl:variable name="myVar">10</xsl:variable>
  A. <atvtest at1="hello world"/>
  B. <atvtest at1="3 + 2 + $myVar"/> <!-- ¹®ÀÚ¿­·Î Ãë±ÞµÊ -->
  C. <atvtest at1="{3 + 2 + $myVar"/> <!-- ½ÄÀ¸·Î Ãë±ÞµÊ -->
  D. <atvtest at1="u{3+2}"/> <!-- "u5" Ãâ·Â -->
  E. <atvtest at1="yo, substring('hello world',7)"/> <!-- ¹®ÀÚ¿­·Î Ãë±ÞµÊ -->
  F. <atvtest at1="yo, {substring('hello world',7)"/> <!-- "yo, world" Ãâ·Â -->
</test> </xsl:template>

¡Ú p. 171 ¾ðÁ¦ Áß°ýÈ£{}¸¦ »ç¿ëÇÏ¸é ¾ÈµÇ´Â°¡?

<xsl:variable name="myVar">10</xsl:variable>
A. <xsl:value-of select="3+2+$myVar"/> <!-- select ¾ÈÀÇ ³»¿ëÀº ¼ö½ÄÀ¸·Î Ãë±Þ. {}ºÒ°¡ -->
B. <xsl:value-of select="substring('hello world', 7)"/>

¡Ú p.176 <for-each>¸¦ ÀÌ¿ëÇÑ ¸ñÂ÷ ¸¸µé±â

xsl:for-each ¸í·ÉÀº ÁÖ¾îÁø ³ëµåµéÀÇ ÁýÇÕ¿¡ ´ëÇÏ¿© °°Àº ¸í·ÉÀ» ¹Ýº¹ÀûÀ¸·Î ½ÇÇà½ÃŲ´Ù. ÀÌµé ³ëµåµéÀ» ¸í½ÃÇÒ ¶§¿¡´Â XPathÀÇ Ãà ÇÑÁ¤ÀÚ, ³ëµå Å×½ºÆ®, ÇÁ·¹µðÄÉÀÌÆ® ±¸¹®µéÀ» ±×´ë·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù.

<xsl:template match="chapter">
Pictures:
<xsl:for-each select="descendant::figure">
<xsl:value-of select="title"/><xsl:test>
</xsl:test> </xsl:for-each> Chapter:<xsl:apply-templates/> </xsl:template>

ÀÌ°ÍÀº figure ¿ä¼ÒÀÇ title ÀڽĿä¼ÒµéÀ» ¸ðµÎ °¡Á®´Ù°¡ È­¸é¿¡ Ç¥½ÃÇØÁØ´Ù.

¡Ú p.177 for-each ¿Í XPath

xsl:tmeplate ¿ä¼ÒÀÇ match ¼Ó¼º¿¡ XPath Ç¥ÇöÀ» »ç¿ëÇÒ ¼ö ÀÖÁö¸¸, »ç½Ç ±× XPath´Â ÆÐÅÏÀ̶ó°í ¾Ë·ÁÁø XPathÀÇ ºÎºÐÁýÇÕÀ̶ó´Â Á¦ÇÑÀ» °¡Áö°í ÀÖ´Â ¹Ý¸é¿¡, xsl:for-each ¿ä¼ÒÀÇ select ¼Ó¼º¿¡´Â ¿Ïº®ÇÑ XPath Ç¥ÇöÀÌ °¡´ÉÇÏ´Ù.

<xsl:template match="title">
  <xsl:text>title ancestors:</xsl:text>
  <xsl:for-each select="ancestor::*">
    <xsl:value-of select="name()"/>
    <xsl:if test="position() != last()">
      <xsl:text>,</xsl:text>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

<xsl:template match="para"/>

xsl:value-of ¿¡°Ô ¾î¶² ³ëµåµéÀÇ ÁýÇÕÀ» °¡Á®¿À°Ô ÇÏ¸é ±×°ÍÀº ´ÜÁö ±× ¹«¸®¿¡ Àִ ù ¹ø° ³ëµåÀÇ ¹®ÀÚ¿­ Çü½Ä¸¸À» ´øÁ®Áشٴ Á¡ÀÌ´Ù. ÀÌ¿¡ ¹ÝÇØ xsl:for-each´Â ¸¶Âù°¡Áö·Î ¾î¶² ³ëµåµéÀÇ ÁýÇÕÀ» °¡Á®¿À°Ô ÇÏ¸é ±× ÁýÇÕ Àüü¸¦ °¡Á®´Ù ÁØ´Ù.

¡Ú p.180 Àç±Í È£ÃâÀ» ÅëÇÑ ÅÛÇø´ ¹Ýº¹ ¼öÇà

<xsl:template name="hyphens">
  <xsl:param name="howMany">1</xsl:param>
  <xsl:if test="$howMany > 0">

    <xsl:text>-</xsl:text>

    <xsl:call-template name="hyphens">
      <xsl:with-param name="howMany" select="$howMany - 1"/>
    </xsl:call-tempalte>
  </xsl:if>
</xsl:template>

<xsl:template match="sample">
Print 1 hyphen:
  <xsl:call-template name="hyphens"/>
    <xsl:with-param name="howMany" select="3"/>
  </xsl:call-template>

Print 20 hyphens:
  <xsl:call-template name="hyphens">
    <xsl:with-param name="howMany" select="20"/>
  </xsl:call-template>

Print 0 hyphens:
  <xsl:call-template name="hyphens">
    <xsl:with-param name="howMany" select="0"/>
  </xsl:call-tempalte>
</xsl:template>

Àç±Í È£Ãâ¿¡¼­ Áß¿äÇÑ °ÍÀº Àç±Í È£ÃâÀ» ¸ØÃâ Á¶°ÇÀÌ ¾ðÁ¨°¡´Â ¹Ýµå½Ã ÂüÀÌ µÇ¾î¾ß ÇÑ´Ù´Â °ÍÀÌ´Ù.

¡Ú p.184 <xsl:include> ´Ù¸¥ XSL ¹®¼­ Æ÷ÇÔÇϱâ

<xsl:include: href="inlines.xsl"/>

<xsl:template match="chapter">
.... »ý·«

inlines.xslÀÌ Åë°·Î µé¾î°£ °ÍÀº ¾Æ´Ï°í, ±× ³»¿ë¸¸ µé¾î°¬´Ù. ´Ù½Ã ¸»ÇØ ±× ½ºÅ¸ÀÏ ½ÃÆ®ÀÇ xsl:stylesheet ÅÂ±×µé »çÀÌÀÇ ¸ðµç °ÍµéÀÌ ÀÌ XSL³»¿ë¿¡ ³¢¾îµé¾î°£´Ù.

¡Ú p.186 <xsl:import> ´Ù¸¥ XSL ¹®¼­ Æ÷ÇÔÇϱâ

xsl:import´Â ÀÓÆ÷Æ® ½ÃÅ°´Â ½ºÅ¸ÀϽÃÆ®¿¡¼­ ÀÓÆ÷Æ®µÈ ½ºÅ¸ÀϽÃÆ®ÀÇ ¸í·É¾îµéÀ» ÀçÁ¤ÀÇÇÒ ¼ö ÀÖ´Ù. ±× ¿Ü¿£ xsl:include¿Í µ¿ÀÏÇÏ´Ù.

<xsl:import href="inlines.xsl"/>

xsl:import ¿ä¼Ò´Â ½ºÅ¸ÀϽÃÆ®ÀÇ XSLT ³×ÀÓ½ºÆäÀ̽º¿¡ ¼ÓÇÏ´Â ´Ù¸¥ ¾î¶² ¿ä¼Òº¸´Ùµµ ¾Õ¿¡ ¿Í¾ß ÇÑ´Ù.

¡Ú p.192 À̸§À» °¡Áø ÅÛÇø´

ÅÛÇø´¿¡ À̸§À» ÁÖ°í ¸¶Ä¡ ÇÔ¼öó·³ È£Ãâ ÇÒ ¼ö ÀÖ´Ù.

<xsl:template name="boldIt"> <!-- ÅÛÇø´¿¡ À̸§À» ÁÖ¾ú´Ù. -->
  <b><xsl:apply-templates/></b>
</xsl:template>

<xsl:template match="winery">
  <p><xsl:call-template name="boldIt"/></p> <!-- ÅÛÇø´ È£Ãâ!! -->
</xsl:template>

<xsl:template match="product">
  <p><xsl:call-template name="boldIt"/></p>
</xsl:template>

<xsl:template match="year | price">
  <p><xsl:apply-templates/></p>
</xsl:template>

¡Ú p.194 <xsl:message>¸¦ ÀÌ¿ëÇÑ µð¹ö±ë, Debugging, µð¹ö±×

<xsl:param name="bodyTextSize">10pt</xsl:param>

<xsl:template match="/">
  <xsl:if test="$bodyTextSize != '10pt'">
    <xsl:message>bodyTextSize default value overridden with value of
      <xsl:value-of select="$bodyTextSize"/>.
    </xsl:message>
  </xsl:if>
  </xsl:appl-templates>
</xsl:template>

xsl:message ÀÇ Ãâ·Â ³»¿ëÀº XSLTº¯È¯ÀÇ Ãâ·ÂÀ¸·Î °¡Áö ¾Ê°í È­¸é¿¡ ³ª¿Â ´ÙµçÁöÀÇ XSLT ÇÁ·Î¼¼¼­¿¡ µû¶ó ´Ù¸£´Ù.

¡Ú p.196 XSLT ÇÁ·Î¼¼¼­ ½ÇÇà ¸ØÃß±â

<xsl:template match="/">
  <xsl:if test="not(contains($bodyTextSize, 'pt'))">
    <xsl:message terminate="yes">bodyTextSize must be specified in points
    (pt).</xsl:message>
  </xsl:if>
  <xsl:apply-templates/>
</xsl:template>

¡Ú p.199 ÅÛÇø´À¸·Î ó¸®ÇÏÁö ¾Ê°í Áö³ªÃÄ ¹ö¸° ¿ä¼Ò È®ÀÎÇϱâ

<xsl:template match="*">
  <h1><xsl:value-of select="name()"/> ELEMENT UNACCOUNTED
  FOR BY STYLESHEET: <xsl:apply-templates/></h1>
</xsl:template>

´Ù¸¥ ÅÛÇø´¿¡ ÀÇÇØ Ã³¸®µÇÁö ¾ÊÀº ¸ðµç ¿ä¼ÒµéÀÌ <xsl:template match="*">¿¡ ÀÇÇØ Ã³¸®µÈ´Ù.

¡Ú p.209 È®Àå ¿ä¼Ò°¡ Áö¿øµÇ´ÂÁö È®ÀÎÇϱâ

XSLT ÇÁ·Î¼¼¼­°¡ ƯÁ¤ È®Àå ¿ä¼Ò¸¦ ±¸ÇöÇÏÁö ¾Ê¾Ò´Ù¸é, ÇÁ·Î¼¼¼­´Â xsl:fallback ¿ä¼ÒÀÇ ÀÚ½Ä ¿ä¼Ò¸¦ ã¾Æ °á°ú Æ®¸®¿¡ ºÙÀδÙ.

<saxon:assing name="color">blue<xsl:fallback>
  <xsl:message>This XSLT processor doesn't support saxon:assign.
  </xsl:message></xsl:fallback>
</saxon:assing>

´Ù¸¥ ¹æ¹ýÀ¸·Î element-available()À» »ç¿ëÇÑ´Ù.

<xsl:choose>
  <xsl:when test="element-available('saxon:assign')">
    <saxon:assign name="color">blue</saxon:assign>
  </xsl:when>
  <xsl:otherwise>
    <xsl:message>This XSLT processor  doesn't support saxon:assign.
    </xsl:message>
  </xsl:otherwise>
</xsl:choose>

¡Ú p.211 ³»Àå È®Àå ÇÔ¼ö »ç¿ë

È®ÀåÇÔ¼ö°¡ Áö¿øµÇ´ÂÁö È®ÀÎ ÇÑ µÚ¿¡ »ç¿ëÇϱâ

<xsl:choose>
<xsl:when test="function-available('xalan:tokenize')">
  <xsl:for-each select="xalan:tokenize(.,',')">
    <entry><xsl:value-of select="."/></entry>
  </xsl:for-each>
</xsl:when>
</xsl:choose>

¡Ú p.213 »ê¼ú ¿¬»ê ¿¹Á¦(¼ýÀÚ °è»ê)

<numbers>
  <x>4</x>
  <y>3.2</y>>
  <z>11</z>
</numbers>

¡é

A. 4 + 3.2 = 7.2
B. 3.2 - 4 = -0.8
C. 4 * 3.2 = 12.8
D. 11/3.2 = 3.4375
E. 4+3.2*11 = 39.2
F. (4+3.2)*11 = 79.2
G. 11 mod 4 = 3
H. 4 + 3.2 + 11 = 18.2
I. floor(3.2) = 3
J. ceiling(3.2) = 4
K. round(3.2) = 3
L. 11 + count(*) = 14
M. 3.2 + string-length("3.2") = 6.2
N. 11 + "hello" = NaN
<xsl:template match="numbers">
  A. 4 + 3.2 = <xsl:value-of select="x + y"/>
  B. 3.2 - 4 = <xsl:value-of select="y - x"/>
  C. 4 * 3.2 = <xsl:value-of select="x * y"/>
  D. 11/3.2 = <xsl:value-of select="z div y"/>
  E. 4+3.2*11 = <xsl:value-of select="x+y*z"/>
  F. (4+3.2)*11 = <xsl:value-of select="(x+y)*z"/>
  G. 11 mod 4 = <xsl:value-of select="z mod x"/>
  H. 4 + 3.2 + 11 = <xsl:value-of select="sum(*)"/>
  I. floor(3.2) = <xsl:value-of select="floor(y)"/>
  J. ceiling(3.2) = <xsl:value-of select="ceiling(y)"/>
  K. round(3.2) = <xsl:value-of select="round(y)"/>
  L. 11 + count(*) = <xsl:value-of select="11+count(*)"/>
  M. 3.2 + string-length("3.2") = <xsl:value-of select="y + string-length(y)"/>
  N. 11 + "hello" = <xsl:value-of select="z + 'hello'"/>
</xsl:template>

¡Ú p.219 ¹®ÀÚ¿­ »Ì¾Æ³»±â ÇÔ¼öµé

<xsl:template match="verse">
  1. By itself: {<xsl:value-of select="."/>}
  2. {<xsl:value-of select="substring(.,7,6)"/>} <!-- 7¹ø° ¹®ÀÚºÎÅÍ 6¹®ÀÚ -->
  3. {<xsl:value-of select="substring(.,12)"/>}
  4. {<xsl:value-of select="substring-before(.,'dreary')"/>}
  5. {<xsl:value-of select="substring-after(.,'desolation')"/>}
</xsl:template>

¡Ú p.220 ±×¿Ü ¹®ÀÚ¿­ ÇÔ¼öµé

<xsl:template match="verse">
  1. {<xsl:value-of select="concat('length: ', string-length(.))"/>}
  2. {<xsl:if test="contains(.,'light')"><xsl:text>light: yes!</xsl:text></xsl:if>}
  3. {<xsl:if test="starts-with(.,'Seest')">
      <xsl:text>Yes, starts with "Seest"</xsl:text>
      </xsl:if>}
  4. {<xsl:value-of select="normalize-space(.)"/>}
  5. {<xsl:value-of select="translate(.,'abcde','ABCDE')"/>}
</xsl:template>

normalize-space()´Â ÁÖ¾îÁø ¹®ÀÚ¿­ÀÇ ¾Õ°ú µÞºÎºÐ¿¡ ÀÖ´Â °ø¹éÀ» ¾ø¾ÖÁØ´Ù.

¡Ú p.223 text() »ç¿ëÇϱâ

<xsl:template match="binCode">
  <productLocation>
    <row><xsl:value-of select="substring(text(), 1, 2)"/>
    </row>
    <shelf><xsl:value-of select="substring(.,3,1)"/>
    </shelf>
    <prodNum><xsl:value-of select="substring-after(text(), '-')'/>
    </prodNum>
  </productLocation>
</xsl:template>

¿©±â¼­ text()¿Í .Àº µ¿ÀÏÇÑ ¿ªÇÒÀ» ÇÑ´Ù. text()´Â ÁÖ¾îÁø ÄÁÅؽºÆ® ³ëµåÀÇ ÀÚ½Ä ³ëµåÀÎ ÅؽºÆ® ³ëµå¸¦ °¡¸®Å°°í, "."Àº substring()ÀÇ Ã¹¹ø° ÀÎÀÚ·Î »ç¿ëµÇ¾úÀ» ¶§ ³ëµåÀÇ ³»¿ëÀ» ¹®ÀÚ¿­·Î Ç¥ÇöÇÑ °ÍÀ» °¡¸®Å²´Ù.

¡Ú p.225 µÎ ¹®ÀÚ¿­ÀÇ ºñ±³

<xsl:if test=". = 'full of Pomp and Gold'">
  a = "full of Pomp and Gold"
</xsl:if>
<xsl:if test=". != ../c">
  a != ../c
</xsl:if>

µÎ ¹®ÀÚ¿­ÀÇ °°ÀºÁö ´Ù¸¥Áö ¿©ºÎ´Â = ¿Í != ¸¦ ÀÌ¿ëÇÑ´Ù.

¡Ú p.228 ¹®ÀÚ¿­ ġȯ ÅÛÇø´

<xsl:template name="globalReplace">
  <xsl:param name="outputString"/>
  <xsl:param name="target"/>
  <xsl:param name="replacement"/>
  <xsl:choose>
    <xsl:when test="contains($outputString, $target)">

      <xsl:value-of select="concat(substring-before($outputString, $target), $replacement)"/>
      <xsl:call-template name="globalReplace">
        <xsl:with-param name="outputString" select="substring-after($outputString, $target)"/>
        <xsl:with-param name="target" select="$target"/>
        <xsl:with-param name="replacement" select="$replacement"/>
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$outputString"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template match="text()">
  <xsl:call-template name="globalReplace">
    <xsl:with-param name="outputString" select="."/>
    <xsl:with-param name="target" select="'finish'"/>
    <xsl:with-param name="replacement" select="'FINISH'"/>
  </xsl:call-template>
</xsl:template>

<xsl:template match="@*|*">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

¡Ú p.234 º¯¼öÀÇ ¼±¾ð°ú »ç¿ë

<xsl:variable name="bodyTextSize">10pt</xsl:variable>

<xsl:template match="winery">
  <b><font size="{$bodyTextSize}"><xsl:apply-template/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="../@grape"/></font><b><br/>
</xsl:template>

<xsl:template match="product">
  <i><font size="{$bodyTextSize}">
  <xsl:apply-templates/></font></i><br/>
</xsl:template>

<xsl:template match="year | price">
  <font size="{$bodyTextSize}"><xsl:apply-templates/></font><br/>
</xsl:template>

°á°ú Æ®¸®¿¡ ¹Ý¿µµÇ´Â ¿ä¼ÒÀÇ ¼Ó¼º°ªÀÌ º¯¼ö³ª ¸Å°³º¯¼ö°¡ °¡¸®Å°´Â °ªÀ» ³ÖÀ¸·Á°í ÇÒ ¶§, ´Þ·¯ ±âÈ£°¡ ºÙÀº º¯¼ö°¡ ±×´ë·Î ÂïÈ÷Áö ¾Ê°Ô Çϱâ À§ÇØ À§ ¿¹Ã³·³ Áß°ýÈ£¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù. ¼Ó¼ºÀÌ ¾Æ´Ï¶ó ¿ä¼ÒÀÇ ³»¿ë¿¡¼­ º¯¼ö¸¦ ÂüÁ¶Çϱâ À§Çؼ­´Â xsl:value-of ±¸¹®À» »ç¿ëÇؾßÇÑ´Ù.
* º¯¼ö ¼±¾ð½Ã select ¸¦ ÀÌ¿ëÇÏ¿© µ¿ÀûÀÎ °ªÀ» ÁÙ ¼ö ÀÖ´Ù.

<xsl:variable name="baseFontSize" select="8"/>
<xsl:variable name="bodyTextSize" select="concat($baseFontSize+2, 'pt')" />

¿©±â¼­ $bodyTextSize´Â '10pt' °¡ µÈ´Ù.
º¯¼ö´Â Áö¿ª¼ºÀ» °®´Â´Ù. µ¿ÀÏÇÑ À̸§À» °®´õ¶óµµ ¼±¾ð Áö¿ªÀÌ ´Ù¸£¸é ´Ù¸¥ º¯¼öÀÌ´Ù.

¡Ú p.237 º¯¼ö¸¦ »ç¿ëÇÏ¿© ¹®ÀÚ¿­À» ¿À¸¥ÂÊÀ¸·Î Á¤·ÄÇϱâ

<xsl:output omit-xml-declaration="yes"/>

<xsl:variable name="fieldWidth">12</xsl:variable> <!-- 12Ä­¿¡ ¸ÂÃç ¿À¸¥ÂÊ Á¤·Ä -->

<xsl:template match="color">
  <xsl:variable name="valueLength" select="string-length(.)"/>
  <xsl:variable name="padding" select="$fieldWidth - $valueLength"/>
  <xsl:value-of select="substring('            ',1,$padding)"/>
  <xsl:value-of select="."/>
</xsl:template>

¡Ú p.238 ¸Å°³º¯¼ö(parameter)

xsl:param ±¸¹®Àº xsl:variable°ú °ÅÀÇ °°Áö¸¸ ÇÑ°¡Áö Â÷ÀÌÁ¡ÀÌ ÀÖ´Ù. ±× °ªÀº ´ÜÁö µðÆúÆ® °ªÀ¸·Î¸¸ ´Ù·ç¾îÁö°í, ·±Å¸ÀÓ¿¡¼­ ÀçÁ¤ÀÇ µÉ ¼ö ÀÖ´Ù.

<xsl:param name="bodyTextSize">10pt</xsl:param> <!-- 10pt´Â ·±Å¸ÀӽàÀç ÁöÁ¤ µÉ¼ö ÀÖ´Ù. -->

<xsl:template match="winery">
  <b><font size="{$bodyTextSize}"><xsl:apply-templates/>
  <xsl:text> </xsl:text>
  <xsl:value-of select="../@grape"/></font></b><br/>
</xsl:template>

Áö¿ª ¸Å°³º¯¼ö´Â p.228 ¹®ÀÚ¿­ ġȯ ÅÛÇø´ ÂüÁ¶

¡Ú p.248 Key(Å°)¿¡ ÀÇÇÑ °Ë»ö

(Å°,°ª)ÀÇ ½ÖÀ¸·Î Á¤º¸¸¦ ±¸¼ºÇÏ¿© Å°¿¡ ÀÇÇØ °ªÀ» °Ë»öÇÏ´Â ±¸Á¶

<shirts>
  <colors>
    <color cid="c1">yellow</color>
    <color cid="c2">black</color>
    <color cid="c3">red</color>
    <color cid="c4">blue</color>
    <color cid="c5">purple</color>
    <color cid="c6">white</color>
    <color cid="c7">orange</color>
    <color cid="c7">green</color> <!-- ÀϺη¯ À§¿Í µ¿ÀÏÇÏ°Ô Çß½¿ -->
  </colors>
  
  <shirt colorCode="c4">oxford button-down</shirt>
  <shirt colorCode="c1">poly blend, straight collar</shirt>
  <shirt colorCode="c6">monogrammed, tab collar</shirt>
</shirts>

¡é

  blue oxford button-down
  yellow poly blend, straight collar
  white monogrammed, tab collar

<color>ÀÇ @cid¸¦ Å°·Î ÀÌ¿ëÇؼ­ °Ë»öÇϸé <color>³ëµå ÀÚü°¡ ¸®ÅϵȴÙ. key °Ë»öÀº °Ë»öµÈ ³ëµå¸¦ ¹ÝȯÇÏ´Â °ÍÀÌÁö ¹®ÀÚ¿­(text())À» ¹ÝȯÇÏ´Â °ÍÀÌ ¾Æ´Ï´Ù.

<xsl:key name="colorNumKey" match="color" use="@cid"/> <!-- Å° »ý¼º -->

<xsl:template match="colors"/>

<xsl:template match="shirt">
  <xsl:value-of select="key('colorNumKey', @colorCode)"/> <!-- key(Å°À̸§,Å°) -->
  <xsl:text> </xsl:text><xsl:apply-templates/>
</xsl:template>

¶Ç ´Ù¸¥ ¹æ½ÄÀ¸·Î <color>ÀÇ text()¸¦ Å°·Î ÀÌ¿ëÇÏ¿© <color>³ëµå ¾ò±â

Looking up the color name with the color ID:

c3's color: red
c4's color: blue
c8's color: 
c7's color:
orange green 
Looking up the color ID with the color name:
black's cid: c2
gray's cid: 

À§¿Í °°Àº °á°ú¸¦ ¾òÀ¸·Á¸é,

<xsl:output method="text"/>

<xsl:key name="colorNumKey" match="color" use="@cid"/>
<xsl:key name="colorKey" match="color" use="."/> <!-- color/text()¸¦ Å°·Î ÀÌ¿ë -->

<xsl:variable name="testVar">c4</xsl:variable>
<xsl:variable name="keyName">colorKey</xsl:variable>

<xsl:template match="colors">
Looking up the color name with the color ID:

c3's color: <xsl:value-of select="key('colorNumKey', 'c3')"/>
c4's color: <xsl:value-of select="key('colorNumKey', $testVar)"/>
c8's color: <xsl:value-of select="key('colorNumKey', 'c8')"/> <!-- Á¸ÀçÇÏÁö ¾Ê´Â Å° -->
c7's color:
<xsl:for-each select="key('colorNumKey', 'c7')">
  <xsl:value-of select="."/><xsl:text> </xsl:text>
</xsl:for-each>
Looking up the color ID with the color name:
black's cid: <xsl:value-of select="key($keyName, 'black')/@cid"/>
gray's cid: <xsl:value-of select="key('colorKey', 'gray')/@cid"/>
</xsl:template>

<xsl:template match="shirt"/>

¡Ú p.253 ¸¶Áö¸· figure ÀÚ½Ä ³ëµåÀÇ ¸¶Áö¸· title ¿ä¼ÒÀÇ °ª ¾ò±â

<xsl:value-of select="descendant:figure/title[last()]"/>·Î´Â ¿øÇÏ´Â °á°ú¸¦ ¾òÀ» ¼ö ¾ø´Ù. ÀÌ ¹®ÀåÀº °¢ figure ÀڽijëµåÀÇ ¸¶Áö¸· title ³ëµå¸¦ °¡Á®¿Â´Ù.
¿øÇÏ´Â °á°ú¸¦ ¾òÀ¸·Á¸é,

<xsl:template match="chapter">
  <xsl:for-each select="descendant::figure/title">
    <xsl:if test="position() = 1"> <!-- ¸ÇóÀ½ figure/title¸¸ °¡Á®¿È -->
      First figure title in chapter: <xsl:value-of select="."/>
    </xsl:if>

    <xsl:if test="position() = last()"> <!-- ¸Ç ¸¶Áö¸· figure/title¸¸ °¡Á®¿È -->
      Last figure title in chapter: <xsl:value-of select="."/>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

¡Ú p.254 ¾ËÆĺª ¼øÀ¸·Î óÀ½°ú ¸¶Áö¸· ³ëµå ¾ò±â

<xsl:template match="chapter">
  <xsl:for-each select="descendant::figure/title">
    <xsl:sort/> 
    
    <xsl:if test="position() = 1"> <!-- ¸ÇóÀ½ figure/title¸¸ °¡Á®¿È -->
      First figure title in chapter: <xsl:value-of select="."/>
    </xsl:if>

    <xsl:if test="position() = last()"> <!-- ¸Ç ¸¶Áö¸· figure/title¸¸ °¡Á®¿È -->
      Last figure title in chapter: <xsl:value-of select="."/>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

¡Ú p.255 ÀÚ½Ä ¿ä¼ÒÀÇ °ª¿¡ µû¶ó Á¤·ÄÇÑ µÚ ¸Ç óÀ½°ú ¸¶Áö¸· ³ëµå ¾ò±â

<xsl:template match="employees">
  <xsl:for-each select="employee">
    <xsl:sort select="salary" data-type="number"/> <!-- ¼ýÀڷΠ°£ÁÖÇÏ°í Á¤·ÄÇ϶ó. -->
    <xsl:if test="position() = 1">
      Lowest salary: <xsl:apply-templates/>
    </xsl:if>
  
    <xsl:if test="position() = last()">
      Highest salary: <xsl:apply-templates/>
    </xsl:if>
  </xsl:for-each>
</xsl:template>

¡Ú p.267 HTML Çü½ÄÀ¸·Î Ãâ·Â

XSTL Çü½ÄÀ¸·Î Ãâ·ÂµÇ´Â °á°ú¹°Àº Text¸¦ Á¦¿ÜÇÏ°í well-formed Çü½ÄÀ» µû¶ó¾ß ÇÑ´Ù. ÇÏÁö¸¸ HTMLÀº well-formed ű׸¦ Á¦´ë·Î ÀνÄÇÏÁö ¸øÇÑ´Ù. ±×ÀÇ ÇØ°áÃ¥À¸·Î XSLTÀÇ xsl:output ¿ä°¡ ÀÖ´Ù. ÀÌ ¿ä¼ÒÀÇ method ¼Ó¼º¿¡ "html" À̶ó°í ¾²¸é XSLT ÇÁ·Î¼¼¼­´Â °á°ú¹°À» ¸¸µé¶§ XHTMLÇü½ÄÀ¸·Î ¸¸µéÁö ¾Ê°í HTML·Î ¸¸µç´Ù. ±×·¯¸¶ XSLT ¹®¼­ ÀÛ¼º½Ã¿¡´Â well-formed·Î ¸¸µé¾î¾ß ÇÑ´Ù.

<xsl:output method="html"/>

¡Ú p.270 XML ÆÄÀÏ¿¡ ÀÚ½ÅÀ» ó¸®ÇÒ XSL ÁöÁ¤Çϱâ

<?xml version="1.0"?>
<?xml-stylesheet href="haha.xsl" "type="text/xsl"?>
<root>
µîµî...

¸ðÁú¶ó 1.4, IE 6.0 ¿¡¼­ ¸ðµÎ Àß º¸¿´½¿.

¡Ú p.274 ÇÑ XSLT¹®¼­·Î ¿©·¯ XML ¹®¼­ ó¸®

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:template match="shirts">
  <shirts>
    <!-- ¿©±â¼­ xq1.xml À» Àо XSLTÀû¿ë -->
    <xsl:apply-templates select="document('xq1.xml')"/>
    <xsl:apply-templates/>
  </shirts>
</xsl:template>

<xsl:tempalte match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

¡Ú p.275 ´Ù¸¥ XML¹®¼­ÀÇ ÀϺΠ³ëµå¸¸ °¡Á®¿À±â

<xsl:template match="shirts">
  <shirts>
  <!-- ¼Ó¼º cid°¡ 'c7'Àΰ͸¸ °¡Àú¿À¶ó. -->
  <xsl:apply-templates select="document('xq1.xml')//*[@cid='c7']"/>
  <xsl:apply-templates/>
  </shirts>
</xsl:template>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

¡Ú p.276 ´Ù¸¥ XML¹®¼­¸¦ °¡Á®¿Í Key·Î ÀÌ¿ëÇϱâ

<!-- ´Ù¸¥ ¹®¼­ »ðÀÔ. ÀÌ ¹®¼­¿¡ <color>³ëµå°¡ ÀÖ´Ù. -->
<xsl:variable name="colorLookupDoc" select="document('xq1.xsl')"/>
<xsl:key name="colorNumKey" match="color" use="@cid"/>

<xsl:template match="shirts">
  <xsl:apply-templates select="$colorLookupDoc"/>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="colors"/>
<xsl:template match="shirts">
  <xsl:variable name="shirtColor" select="@colorCode"/>
  <xsl:for-each select="$colorLookupdoc">
    <xsl:value-of select="key('colorNumKey', $shirtColor)"/>
  </xsl:for-each>
  <xsl:text> </xsl:text><xsl:apply-templates/><xsl:txt>
  </xsl:text>
</xsl:template>

¡Ú p.279 mode¸¦ ÀÌ¿ëÇØ ÇÑ ³ëµåÁýÇÕ¿¡ µÎ °³ ÀÌ»óÀÇ ÅÛÇø´ Á¤ÀÇ - Â÷·Ê¿Í ¸ñ·Ï ¸¸µé±â

<xsl:template match="story">
<html>
    <body>
  <h1>Table of Conetnts</h1>
  <xsl:apply-templates select="chapter/title" mode="toc"/>
  <xsl:apply-templates/></body></html>
</xsl:template>

<xsl:template match="chapter/title">
  <h2><a name="{generate-id()}"/><xsl:apply-templates/></h2>
</xsl:template>

<xsl:template match="chapter/title" mode="toc">
  <p><a href="#{generate-id()}"><xsl:apply-templates/></a></p>
</xsl:template>

<xsl:template match="para">
  <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="story/title">
  <h1><xsl:apply-templates/></h1>
</xsl:template>

¡Ú ÀÏ¹Ý Text °á°ú¹° ¸¸µé±â

¡Ú p.286 ¹øÈ£ ºÙÀ̱â(Numbering)

<!-- ÀϹÝÀûÀΠ¹æ¹ý. Ç׸ñ ¾Õ¿¡ ¼ýÀÚ¿Í Á¡ °ø¹é ³Ö±â -->
<xsl:template match="color">
  <xsl:number/>. <xsl:apply-templates/>
</xsl:template>

<!-- ¼ýÀÚ Çü½Ä Æ÷¸ËÆà-->
<xsl:template match="colors">
  <xsl:for-each select="color">
    <xsl:number format="I. "/><xsl:value-of select="."/> <!-- I. II. III. Çü½Ä -->
  </xsl:for-each>

  <xsl:for-each select="color">
    <xsl:number format="i. "/><xsl:value-of selet="."/> <!-- i. ii. iii. Çü½Ä -->
  </xsl:for-each>
  
  <xsl:for-each select="color">
    <xsl:number format="A. "/><xsl:value-of select="."/> <!-- A. B. C. Çü½Ä -->
  </xsl:for-each>

  <xsl:for-each select="color">
    <xsl:number format="a. "/><xsl:value-of select="."/> <!-- a. b. c. Çü½Ä -->
  </xsl:for-each>
</xsl:template>

  <xsl:template match="color">
    <xsl:number format="001. "/><xsl:templates/> <!-- 001. 002. 003. Çü½Ä -->
  </xsl:template>

xsl:number¿¡ grouping-separator ¿ä¼ÒÀÇ °ªÀ¸·Î ","¸¦ ÁÖ°í grouping-size ¿ä¼Ò¿¡ 3À» ÇÒ´çÇϸé 999¸¦ ³Ñ´Â ¼ýÀÚ¿¡ ´ëÇؼ­ ¼¼ ÀÚ¸®¸¶´Ù ÄÞ¸¶¸¦ Âï¾îÁØ´Ù.

¡Ú p.290 multiple ³Ñ¹ö¸µ

<xsl:template match="color">
  <xsl:number level="multiple" format="1. "/>
  <xsl:apply-templates/>
</xsl:template>

´ÙÀ½°ú °°Àº Çü½ÄÀÇ °á°ú¸¦ ¾ò°ÔµÈ´Ù.

1. red
2. green
3. blue
  3.1 robin's egg
  3.2 haha
4. yellow

¡Ú p.293 ¿©·¯ ´Ü°èÀÇ ³ëµå¿¡ ´ëÇØ multiple ³Ñ¹ö¸µ

<xsl:template match="chapter">
  <xsl:number format="1. "/>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="sect1">
  <xsl:number format="1. " level="multiple" count="chapter|sect1"/>
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="sect2">
  <xsl:number format="1. " level="multiple" count="chapter|set1|sect2"/>
  <xsl:apply-templates/>
</xsl:template>

´ÙÀ½°ú °°Àº Çü½ÄÀÇ °á°ú¸¦ ¾ò°ÔµÈ´Ù.

1.
  1.1
  1.2
2.
  2.1
    2.1.1
    2.1.2
  2.2

¡Ú p.294 ³ëµåÀÇ ±íÀÌ¿¡ °ü°è ¾øÀÌ ¹®¼­ Àüü¿¡ °ÉÃÄ ¼øÂ÷ÀûÀÎ ³Ñ¹ö¸µ

<xsl:template match="figure">
  <xsl:number format="1. " level="any"/><xsl:apply-templates/>
</xsl:template>

figure°¡ ¾î´À ³ëµåÀÇ ÀÚ½ÄÀ̵çÁö °£¿¡ ¹øÈ£°¡ ¼ø¼­´ë·Î ¸Ô¿© Áø´Ù.

¡Ú p.295 ³ëµåÀÇ ±íÀÌ¿¡ °ü°è ¾ø°í, ƯÁ¤ Á¶»ó ű׸¶´Ù ¹øÈ£¸¦ ´Ù½Ã ½ÃÀÛÇÏ´Â ³Ñ¹ö¸µ

<xsl:template match="figure">
  <xsl:number format="1. " level="any" from="chapter"/>
  <xsl:apply-templates/>
</xsl:template>

xsl:number ¿ä¼Ò¸¦ ÀÚÁÖ »ç¿ëÇϸé XSLT ÇÁ·Î¼¼¼­ÀÇ ¼Óµµ°¡ ¶³¾îÁø´Ù. µÇµµ·Ï position()À» »ç¿ëÇ϶ó.

<xsl:template match="colors">
  <xsl:for-each select="color">
    <xsl:value-of select="position()"/>. <xsl:value-of select="."/>
    <xsl:text>
</xsl:text>
  </xsl:for-each>
</xsl:template>

¿©±â¼­ ²À xsl:for-each¸¦ ½á¾ßÇÑ´Ù. ±×³É xsl:template À» »ç¿ëÇÏ¸é ¾ÈµÈ´Ù. XSLT ÇÁ·Î¼¼¼­´Â colors ¿ä¼ÒµéÀÇ ÀÚ½Ä ¿ä¼Òµé Áß¿¡ °¢ color ¿ä¼Òµé »çÀÌÀÇ °³Ç๮ÀÚ¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Â ÅؽºÆ® ³ëµå±îÁö Æ÷ÇÔÇÏ¿© °¢ color ¿ä¼ÒÀÇ À§Ä¡¸¦ °è»êÇÑ´Ù.

¡Ú p.301 ¼ýÀÚ¿¡ ÀÇÇÑ Á¤·Ä / ¿ª¼ø Á¤·Ä

<xsl:template match="employees">
  <xsl:apply-templates>
    <xsl:sort select="salary" data-type="number" order="descending"/>
  </xsl:apply-templates>
</xsl:template>

¡Ú p.301 ´ÙÁß Á¤·Ä

<xsl:template match="employees">
  <xsl:apply-templates>
    <xsl:sort select="last"/> <!-- last/first´Â ¿ä¼ÒÀÇ À̸§ÀÓ -->
    <xsl:sort select="first"/>
  </xsl:apply-templates>
</xsl:template>

¡Ú p.303 ¼Ó¼º¿¡ ÀÇÇÑ Á¤·Ä(³¯Â¥ ¼ø)

<xsl:template match="employees">
  <xsl:apply-templates>
    <!-- hireDate´Â 04/23/1999 Çü½ÉÀÓ -->
    <xsl:sort select="substring(@hireDate, 7, 4)"/> <!-- year -->
    <xsl:sort select="substring(@hireDate, 1, 2)"/> <!-- month -->
    <xsl:sort select="substring(@hireDate, 3, 2)"/> <!-- day -->
  </xsl:apply-templates>
</xsl:template>

¡Ú p.305 ¼ÕÀÚ ¿ä¼Ò¿¡ ÀÇÇÑ Á¤·Ä

<xsl:template match="winelist">
  <xsl:copy>
    <xsl:apply-templates>
      <xsl:sort data-type="number" select="prices/discounted"/> <!-- ¼ÕÀÚ ¿ä¼Ò¸¦
      Á¶°ÅÀ¸·Î -->
    </xsl:templates>
  </xsl:copy>
</xsl:template>

<xsl:template match="*"
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

xsl:sort´Â xsl:for-each¿Í ÇÔ²² ¾µ¶§ °­·ÂÇØÁø´Ù.

¡Ú p.313 XML¹®¼­ »ý¼ºÇϸç Doctype »ðÀÔ

<xsl:output method="xml" doctype-system="../dtds/docbookx.dtd"
  doctype-public="-//OASIS//DTD DocBook XML//EN"/>

<xsl:template match="@*|node()">
¾î¼±¸...

¾Æ·¡ ¹®±¸°¡ »ðÀԵȴÙ. ¾Æ·¡¿¡¼­ chapter´Â »ý¼ºµÉ xml ¹®¼­ÀÇ root ¿ä¼ÒÀÌ´Ù.

<!DOCTYPE chapter
  PUBLIC "-//OASIS//DTD DocBook XML/EN" "../dtds/docbookx.dtd">

[ ] ¾È¿¡ DTD ¼±¾ðÀ» ³ÖÀ» ¼ö´Â ¾ø´Ù. System ¼Ó¼º¿¡ ÀÖ´Â ¿ÜºÎ DTD¿¡ ¸ðµç ¼±¾ðÀ» ³Ö¾î¾ß ÇÑ´Ù.

¡Ú p.315 XML ¼±¾ð ³Ö±â

<xsl:output method="xml" version="1.0" encoding="utf-8"/>

À§ ¼±¾ð¿¡ ÀÇÇØ »ý¼ºµÈ xml ÆÄÀÏÀº ´ÙÀ½À¸·Î ½ÃÀ۵ȴÙ.

<?xml version="1.0" encoding="utf-8"?>

¡Ú p.316 XML ¼±¾ð »©±â

ÀÚµ¿À¸·Î µé¾î°¡´Â ¼±¾ðÀ» »©·Á¸é..

<xsl:output method="xml" omit-xml-declaration="yes"/>

¡Ú p.318 ƯÁ¤ ¿ä¼Ò°¡ °®°í ÀÖ´Â ºÒÇÊ¿äÇÑ °ø¹éÀ» ¹®¼­ Àüü¿¡ °ÉÃÄ Á¦°Å

<xsl:strip-space elements="color"/>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

À§ÀÇ ½ºÅ¸ÀÏ ½ÃÆ®´Â ¿øº» XML¿¡¼­ color ¿ä¼ÒÀÇ °ø¹éÀ» Á¦°ÅÇÏ°í ¸ðµç ³»¿ëÀ» ±×´ë·Î º¹»çÇÑ´Ù.

¡Ú p.320 °ø¹é ±×³É ³öµÎ±â

<xsl:strip-space elements="*"/> <!-- ¸ðµç ¿ä¼ÒÀÇ °ø¹éÀ» Á¦°ÅÇ϶ó -->
<!-- codeListing°ú sampleOutput¸¸ »©°í -->
<xsl:preserve-space elements="codeListing sampleOutput"/>

¡Ú p.321 µé¿©¾²±â(indentation) : xml ¹®¼­¸¦ Àû´çÈ÷ µé¿©¾²±â ÇÑ´Ù.

<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

indent="yes"¿¡ ÀÇÇØ µé¿©¾²±â°¡ µÈ´Ù.

¡Ú p.326 °ø¹é°ú °³Ç๮ÀÚ, Tab¹®ÀÚ Ã³¸®

°ø¹é°ú °³Ç๮ÀÚ¸¦ ¿£Æ¼Æ¼·Î ¼±¾ðÇÏ¸é »ç¿ëÇϱ⠽±´Ù.

<!DOCTYPE stylesheet [
ENTITY space "<xsl:text> </xsl:text>"
ENTITY cr "<xsl:text>
</xsl:text>"
ENTITY tab "<xsl:text>  </xsl:text>"
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes"/>
  <xsl:template match="employee">
    <xsl:apply-templates select="@hireDate"/>&cr;
    <xsl:apply-templates select="first"/>&space;&tab; <!-- °ø¹é°ú ÅÇ »ðÀÔ -->
    <xsl:apply-templates select="last"/>
  </xsl:template>
</xsl:stylesheet>

XML ÇÁ·Î¼¼¼­´Â ¿ä¼Ò ¾È¿¡ ´Ù¸¥ ¹®ÀÚ µ¥ÀÌÅÍ¿Í ÇÔ²² °³Çà ¹®ÀÚ°¡ µé¾î°¡ ÀÖÀ¸¸é À̸¦ Á¦°ÅÇÏÁö ¾Ê´Â´Ù. ÀÏ¹Ý ¹®ÀÚ¿­¿¡¼­ °³Çà ¹®ÀÚ°¡ ÀÛµ¿ÇÏÁö ¾Ê°Ô ÇÏ·Á¸é <xsl:text>¸¦ ÀÌ¿ëÇÑ´Ù.

<xsl:text>Date</xsl:text>

¡Ú p.334 À¯ÀÏÇÑ ID »ý¼º

<xsl:template match="chapter | sect1 | sect2">
  <xsl:copy>
    <xsl:attribute name="uid">
      <xsl:value-of select="generate-id(.)"/> <!-- ID »ý¼º -->
    </xsl:attribute>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

¡Ú p.336 generate-id()¸¦ ÀÌ¿ëÇÑ ¹®¼­³» ÀÚµ¿ ¸µÅ© »ý¼º

<xsl:output method="html"/>

<xsl:template match="chapter">
  <html>¡¡¡¡¡¡¡¡¡¡¡¡<body¡¡¡¡¡¡¡¡¡¡¡¡>
    <!-- Generate a list of picture titles, with each title linking to the picture in the
    poem below -->
    <b>Pictures:</b><br/>
    <xsl:for-each select="descendant::figure">
      <a href="#{generate-id(graphic)}">
      <xsl:value-of select="title"/></a><br/>
    </xsl:for-each>

    <xsl:apply-templates/>
  </body></html>
</xsl:template>

<xsl:template match="para">
  <p><xsl:apply-templates/></p>
</xsl:template>

<xsl:template match="graphic">
  <!-- À§¿¡ °¢ graphic ¿ä¼Ò¸¶´Ù »ý¼ºµÈ id¿Í µ¿ÀÏÇÑ id°¡ »ý¼ºµÈ´Ù. -->
  <center><a name="{generate-id(.)}"><img src=http://img.yahoo.co.kr/blank.gif></a>
  <b><xsl:value-of select="../title"/></b></center>
</xsl:template>

<xsl:template match="figure/title"/>

</xsl:stylesheet>

¡Ú ¹®¼­ Àüü¸¦ ±×´ë·Î º¹»çÇÏ¸ç ºÒÇÊ¿äÇÑ ³ëµå »èÁ¦Çϱâ

<!-- ¾Æ·¡´Â ¹®¼­ Àüü¸¦ ±×´ë·Î º¹»çÇÑ´Ù -->
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<!-- ¾Æ·¡¿¡ ÀÇÇØ ºÒÇÊ¿äÇÑ ³ëµå°¡ »èÁ¦µÈ´Ù. -->
<xsl:template match="ºÒÇÊ¿äÇÑ ³ëµå"/>