다음을 통해 공유


<xsl:attribute-set>의 예제

다음 예제에서는 title-style이라는 명명된 특성 집합을 만들고 템플릿 규칙에 이 집합을 사용합니다.

XML 파일(book.xml)

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="attrset.xsl" ?>
<book>
   <chapter>
      <heading>The First Heading</heading>
   </chapter>
   <chapter>
      <heading>The Next Heading</heading>
   </chapter>
</book>

XSLT 파일(attrset.xsl)

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

<xsl:template match="chapter/heading">
  <fo:block quadding="start" xsl:use-attribute-sets="title-style">
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>

<xsl:attribute-set name="title-style">
  <xsl:attribute name="font-size">12pt</xsl:attribute>
  <xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:attribute-set>

</xsl:stylesheet>

출력

다음은 형식이 지정된 출력입니다.

다음은 쉽게 구별할 수 있도록 줄 바꿈을 추가한 프로세서 출력입니다.

<?xml version="1.0"?>
<fo:block font-size="12pt" 
          font-weight="bold" 
          quadding="start" 
          xmlns:fo="http://www.w3.org/1999/XSL/Format">
The First Heading
</fo:block>
<fo:block font-size="12pt" 
          font-weight="bold" 
          quadding="start" 
          xmlns:fo="http://www.w3.org/1999/XSL/Format">
The Next Heading
</fo:block>

참고 항목

참조

<xsl:attribute> 요소

<xsl:element> 요소

<xsl:copy> 요소