前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布

XSL

作者头像
全栈程序员站长
发布2022-07-04 12:55:19
1.1K0
发布2022-07-04 12:55:19
举报
文章被收录于专栏:全栈程序员必看

第一部分学了7个元素,还有24个,一个一个学吧。

  1、<xsl:import>、<xsl:include>、<xsl:apply-imports>元素   <xsl:import>与<xsl:include>相比,两者都须是<xsl:stylesheet>的子结点,但前者定义的模板规则优先级比较低,且必须为第一个子结点。两者的功能是相同的,都是将另一个定义好的XSL文件装入到当前XSL文件中来。   装来的模板规则,由<xsl:apply-imports>指定何时何地使用。   它们的语法分别是:

<xsl:import href=”URI”/> <xsl:apply-templates />

  2、<xsl:attribute>、<xsl:attribute-set>元素   前者用以给元素增加属性,已有同名属性则被它替换。后者是<xsl:stylesheet>的子结点,用来定义一组属性,将其用于整个文档。语法如下:

<xsl:attribute name=”attributename” namespace=”uri”><!– Content:template –></xsl:attribute> <xsl:attribute-set name=”name” use-attribute-sets=”name-list”><!– Content:xsl:attribute* –></xsl:attribute-set>

  namespace可选,use-attribute-sets可选,用以使用其它预定义的attribute-set.

  3、<xsl:param>、<xsl:call-template>、<xsl:with-param>元素   <xsl:param>用来定义全局参数(是<xsl:styelsheet>的子点时)或局域参数(在一个模板内时),<xsl:call-template>用来调用指定的模板,<xsl:with-param>则用来调用模板或使用模板时传递参数。需要说明的是,with-param的name属性的值必须与预定义的值一致。语法如下:

<xsl:param name=”name” select=”expression”><!– Content:template –></xsl:param> <xsl:call-template name=”templatename”><!– Content:xsl:with-param* –></xsl:call-template> <xsl:with-param name=”name” select=”expression”><!– Content:template –></xsl:with-param>

  其中的select都是可选的,前者的select用来指定默认值,后者可以来传值(也可用标签的 内容传值)。

  4、<xsl:variable>元素   定义全局或局部变量,其一旦赋值,不能改动。语法:

<xsl:variable name=”name” select=”expression”><!– Content:template –></xsl:variable>

  5、<xsl:copy>、<xsl:copy-of>元素   两者都复制当前节点及其命名空间,但后者还复制子结点和当前结点属性。语法如下:

<xsl:copy-of select=”expression”/> <xsl:copy use-attribute-sets=”name-list”><!– Content:template –></xsl:copy>

其中use-attribute-sets可选。

  6、<xsl:comment>元素   在结果树中生成一个注释结点。语法如下:

<xsl:comment><!– Content:template –></xsl:comment>

  7、<xsl:decimal-format>元素   定义那些在调用函数format-number()进行由数字向字符器转换的过程中用到的一些特殊字符或符号。语法如下:

<xsl:decimal-format name=”name” decimal-separator=”char” grouping-separator=”char” infinity=”string” minus-sign=”char” NaN=”string” percent=”char” per-mille=”char” zero-digit=”char” digit=”char” pattern-separator=”char”/>

所有项是可选的。

  8、<xsl:element>元素   在结果树上生成一个元素,语法如下:

<xsl:element name=”name” namespace=”URI” use-attribute-sets=”namelist”><!– Content:template –></xsl:element>

其中后两个属性是可选的,前俩者的值可在实时运行时算出。

  9、<xsl:fallback>元素   当xsl的元素不能被处理器识别时,调用fallback提供的备用程序。

<xsl:fallback><!– Content: template –></xsl:fallback>

  10、<xsl:key>元素   这是一个顶层元素,定义一个KEY供Key函数使用。

<xsl:key name=”name” match=”pattern” use=”expression”/>

  11、<xsl:message>元素   用来输出信息,如错误信息。所有的其它元素都可出现在其内容中。

<xsl:message terminate=”yes|no”> <!– Content:template –></xsl:message>

  12、<xsl:namespace-alias>元素   用来在输出时将某命名空间替换为另一个。

<xsl:namespace-alias stylesheet-prefix=”prefix|#default” result-prefix=”prefix|”#default”/>

  13、<xsl:number>元素   用以标明当前结点在源树中的顺序,也可以用格式化一个数。

<xsl:number count=”expression” level=”single|multiple|any” from=”expression” value=”expression” format=”formatstring” lang=”languagecode” letter-value=”alphabetic|traditional” grouping-separator=”character” grouping-size=”number”/>

  14、<xsl:output>元素   用以定义output的格式,

<xsl:output method=”xml|html|text|name” version=”string” encoding=”string” omit-xml-declaration=”yes|no” standalone=”yes|no” doctype-public=”string” doctype-system=”string” cdata-section-elements=”namelist” indent=”yes|no” media-type=”string”/>

  15、<xsl:preserve-space>、<xsl:strip-space>元素   两者用来指明元素内容的空格保留还去掉。由于默认是保留的,所以只有在用了去掉时才需指明保留者。

<xsl:preserve-space elements=”list-of-element-names”/> <xsl:strip-space elements=”list-of-element-names”/>

  list-of-element-names的值中可用*通配符。

  16、<xsl:processing-instruction>元素   用来向输出写处理指令,如指定css文件等。

<xsl:processing-instruction name=”process-name”><!– Content:template –></xsl:processing-instruction>

  17、<xsl:text>元素   用来输出字串常量。

<xsl:text disable-output-escaping=”yes|no”> <!– Content:#PCDATA –></xsl:text>

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/111118.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021年7月2,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档