次の方法で共有


Example of <xsl:attribute-set> 

The following example creates a named attribute set called title-style and uses it in a template rule.

XML File (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 File (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>

Output

This is the formatted output:

The following is the processor output, with line breaks added for clarity.

<?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>

See Also

Reference

<xsl:attribute> Element
<xsl:element> Element
<xsl:copy> Element