Á¦5Àå. XSL Transformation

È帧 Á¦¾î ¿¤¸®¸ÕÆ®

º¯È¯ ½ºÅ¸ÀÏ 6 º¯È¯ ½ºÅ¸ÀÏ 7
<xsl:template match="/">
   <HTML><BODY>
   <table border="1">
      <tr>  <th>À̸§/ÀüÈ­</th><th>»çÁø</th>  </tr>
      <xsl:apply-templates/>
   </table>
   </BODY></HTML>
</xsl:template>

<xsl:template match="entry">
   <tr valign="top">
   <td><xsl:apply-templates select="name"/>
         <xsl:apply-templates select="tel"/></td>
   <td><xsl:apply-templates select="pic"/></td>
   </tr>
</xsl:template>

<xsl:template match="name">...
<xsl:template match="/">
   <HTML><BODY>
   <table border="1">
      <tr>  <th>À̸§/ÀüÈ­</th><th>»çÁø</th> </tr>
      <xsl:for-each select="//entry">
         <tr valign="top">
         <td><xsl:apply-templates select="name"/>
               <xsl:apply-templates select="tel"/></td>
         <td><xsl:apply-templates select="pic"/></td>
         </tr>
      </xsl:for-each>
   </table>
   </BODY></HTML>
</xsl:template>

<xsl:template match="name">...
<xsl:template match="tel">...
<xsl:template match="pic"><img>...

1) °¡°ÝÇ¥½Ã Á¦´ë·Î Çϱâ : $***¿ø
2) Ç¥·Î ¸¸µé±â (Àç°í ¾ø´Â µµ¼­ Á¦¿Ü)
3) ¸ñ·ÏÀ¸·Î ¸¸µé±â

µµ¼­ ½ºÅ¸ÀÏ 0 µµ¼­ ½ºÅ¸ÀÏ 2
<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:value-of select="price"/>¿ø<br/>
   <B><I>Àç°í : </I></B>
         <xsl:value-of select="@InStock"/>±Ç<P/>
</xsl:template>
<xsl:template match="/">
   ... <xsl:apply-templates /> ...
</xsl:template>

<xsl:template match="book">
   <B><I>Á¦¸ñ : </I></B> <... select="title"/><br/>
   <B><I>ÀúÀÚ : </I></B> <... select="author"/><br/>
   <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:value-of select="@InStock"/>±Ç<P/>
</xsl:template>
µµ¼­ ½ºÅ¸ÀÏ 4 µµ¼­ ½ºÅ¸ÀÏ 5
<xsl:template match="/"> ...
   <table border="1">
   <tr> <th>Á¦¸ñ</th><th>ÀúÀÚ</th><th>... <th>... </tr>
   <xsl:apply-templates />
   </table> ...
</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:template match="/">
   <HTML><BODY> ... 
   <OL>
   <xsl:apply-templates />
   </OL>
   </BODY></HTML>
</xsl:template>

<xsl:template match="list">
   <xsl:for-each select="book">
      <LI><xsl:value-of select="author"/>,
      <xsl:value-of select="title/text()"/>,
      <xsl:choose> $  ...  ¿ø </xsl:choose> 
      (<xsl:value-of select="@InStock"/>±Ç)
      </LI>
   </xsl:for-each>
</xsl:template>

HTML º¯È¯ ¿¹Á¦ (±³Àç) 

º¯È¯ °á°ú º¯È¯ °á°ú (HTML ÆÄÀÏ)

XML Style Sheet ( Oct 2001 ) ©

Table of Contents send comments to sblim@sookmyung.ac.kr .

Styling

Style Sheets ... XSL, see http://www.w3.org/Style ...

How XSL works

An XSL style sheet is ... , paragraph and keywords.
<HTML>
<HEAD>
<TITLE> XML Style Sheet </TITLE>
<META NAME="keywords" CONTENT="XML, XSL ">

</HEAD>
<BODY>
<H2>XML Style Sheet ( Oct 2001 ) &copy;</H2>
<B>Table of Contents</B>
<UL>
  <LI> <A HREF="#N27">Styling</A> </LI>
  <LI> <A HREF="#N39">How XSL works</A> </LI>
</UL>
send comments ...
<P><I><B><A NAME="N27"></A>
Styling</B></I></P>
Style Sheet ...
<P><I><B><A NAME="N39"></A>
How XSL works</B></I></P>
An XSL ¡¦
</BODY>
</HTML>
³í¹®º¯È¯ 1 ³í¹® º¯È¯ 2
<xsl:template match="/">
   <HTML>
   <HEAD> <TITLE>
      <xsl:value-of select="article/title"/> </TITLE>
   <META NAME="keywords">
      <xsl:attribute name="CONTENT">
         <xsl:value-of select="/article/keywords"/>
      </xsl:attribute>
   </META> </HEAD>
   <BODY>
   <H3><xsl:value-of select="article/title"/> 
   (
<xsl:value-of select="article/date"/> ) &#0169;
 
</H3>
   <xsl:apply-templates/>
   </BODY>
   </HTML>
</xsl:template>

<xsl:template match="section/title"> ...
<xsl:template match="url"> ... 
<xsl:template match="url[@protocol='mailto']"> ...
<xsl:template match="p"> ... 
<xsl:template match="section[0]/p"> ... 
<xsl:template match="article/title | abstract | date | keywords" />
<xsl:template match="/">
   <HTML>  <BODY>
   <H3><...".../title"/>(<...".../date"/>) &#0169;</H3>
   <P><B>Table of Contents</B></P>
   <UL>
   <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>
   </UL>
   <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>
...
<?xml version="1.0" encoding="EUC-KR"?>
<!DOCTYPE xsl:stylesheet [
   <!ENTITY xxx "&#0169;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl=
      "http://www.w3.org/1999/XSL/Transformation">

<xsl:output method="html" />

<xsl:template match="/">
   <HTML>  <HEAD>...</HEAD>
   <BODY>
   <H2> <xsl:call-template name="title"/> &xxx;</H2>
   ...
      <LI><A> <xsl:attribute name="HREF">
         #<xsl:value-of select="generate-id()"/></xsl:attribute>
      <xsl:value-of select="."/></A></LI>
   ...
</xsl:template>

<xsl:template name="title">
   <xsl:value-of select="article/title" /> 
    <xsl:value-of select="article/date" /> 
</xsl:template>


<xsl:template match="section/title"> ... 
   <A><xsl:attribute name="NAME">
           <xsl:value-of select="generate-id()"/>
         </xsl:attribute></A>
   <xsl:apply-templates/> ...
</xsl:template> ...

HTML ¿£Æ¼Æ¼ ¼±¾ð &xxx;
   - XML¿¡ ¾ø´Â ¿£Æ¼Æ¼¸¦ À§ÇÑ DTD




Ãâ·Â °á°ú°¡ html ÆÄÀÏ



ÅÛÇø®Æ® È£Ãâ 
   (¾Æ·¡¿¡ "title"À̶ó´Â ÅÛÇø®Æ® Á¤ÀÇ)
¿£Æ¼Æ¼ »ç¿ë &xxx;


ÀÓÀÇÀÇ À¯ÀÏ ½Äº°ÀÚ(id) »ç¿ë : #
 
°á°ú :
<LI><A HREF="#N27">Styling</A></LI>
<LI><A HREF="#N39">How XSL ...</A></LI>


ÅÛÇø®Æ® Á¤ÀÇ

È£Ãâ °á°ú : XML Style Sheet ( Oct 2001 )



À¯ÀÏ ½Äº°ÀÚ ¼±¾ð : generate-id()

°á°ú :
...<A NAME="N27"></A>Styling...
...<A NAME="N39"></A>How XSL works...