XSL最全基础教程之xsl:attribute-set元素

 时间:2026-02-14 13:19:33

1、语法

<xsl:attribute-set  

    name = QName  

    use-attribute-sets = QNames> 

</xsl:attribute-set>

2、属性

    name(必需):

    定义该属性集的名称

    use-attribute-sets(可选):

    在该属性由空格分隔,集中使用的其它属性集的列表。

3、示例

创建一个名为book.xml的XML文件

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

<?xml-stylesheet type="text/xsl" href="book.xsl"?>

<book>

    <chapter>

        <heading>The First Chapter</heading>

    </chapter>

    <chapter>

        <heading>The Next Chapter</heading>

    </chapter>

</book>

XSL最全基础教程之xsl:attribute-set元素

4、创建一个名为book.xsl的xsl文件

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

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

XSL最全基础教程之xsl:attribute-set元素

5、测试结果

运行XML Tools选择XSL Transformation

<?xml version="1.0"?>

    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" quadding      ="start" font-size="12pt" font-weight="bold">

         The First Chapter

    </fo:block>

    <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" quadding      ="start" font-size="12pt" font-weight="bold">

         The Next Chapter

     </fo:block>

XSL最全基础教程之xsl:attribute-set元素

  • 节奏海拉鲁 卓拉蛙鞋的获取方法、位置介绍
  • 塞尔达游戏攻略
  • 怪物猎人修炼场怎么去
  • 塞尔达传说:姆吉拉的假面图文攻略 五 冰之神殿
  • 脸黑先生全关卡攻略(下)
  • 热门搜索
    51旅游好去处 海南旅游局官网 重庆旅游景点大全介绍 南充旅游景点 土耳其旅游报价 葫芦岛旅游社 去韩国旅游必买 大山包旅游攻略 陕西旅游集团公司 旅游互联网