您的位置:首页 > Web前端

XSLT Programmer's Reference 读书笔记

2005-09-12 18:01 155 查看
看的是英文电子版,读到一些好句子,摘录一下,大家看着玩玩

There is no explicit provision for XHTML output, but since XHTML is pure XML, it can be written using the XML method in the same way as any other XML document type.

The difference between <xsl:include[/b]> and <xsl:import[/b]> is that conflicting definitions are resolved differently:

<xsl:include[/b]> effectively does a textual inclusion of the referenced stylesheet module, minus its containing <xsl:stylesheet[/b]> element, at the point where the <xsl:include[/b]> element is written. The included module is treated exactly as if its top-level elements, with their contents, appeared in the parent module in place of the <xsl:include[/b]> element itself.

<xsl:import[/b]> also incorporates the top-level elements from the referenced stylesheet module, but in this case the definitions in the imported module have lower import precedence[/b] than the definitions in the parent module. If there are conflicting definitions, the one with higher import precedence will generally win. The detailed rules actually depend on the type of definition, and are given in the specification of <xsl:import[/b]> on page 226, in Chapter 4. Importing a module is thus rather like defining a subclass, in that the parent module can use some definitions unchanged from the imported module, and override others with definitions of its own.

It is an error for a stylesheet module to import or include itself, directly or indirectly, because doing so would define an infinite loop.

It isn't an error, however, for a stylesheet module to be included or imported at more than one place in the stylesheet program.

People often ask for some kind of facility to load stylesheet modules dynamically, based on a decision made while the transformation is running. The simple answer is that you can't do this.

The typical way of using this is to have one stylesheet containing common template rules, followed by more specific stylesheet modules distinguished using the title or media pseudo-attributes. But other products, notably Microsoft's MSXML3, simply use the first stylesheet and ignore the others.

Bitten by years of experience with proprietary vendor extensions to HTML, the W3C committee responsible for XSLT took great care to allow vendor extensions in a tightly controlled way.

What this means in practice is that if you want to be specific about whitespace characters, write them as character references; if you just want to use them as separators and padding, use the whitespace characters directly.

Unlike variables in many programming languages, XSLT variables cannot be updated[/b]. Once they are given an initial value, they retain that value until they go out of scope. This feature has a profound effect on the programming style used when a stylesheet needs to do calculations. The subject of programming without assignment statements[/i] is discussed in detail in Chapter 9.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: