新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 在这里讨论其他W3C规范
    [返回] 中文XML论坛 - 专业的XML技术讨论区W3CHINA.ORG讨论区 - Web新技术讨论『 其他W3C规范 』 → 最近用XSLT比较多,直接在看W3C的规范,顺便翻译了这些(备份) 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 22436 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 最近用XSLT比较多,直接在看W3C的规范,顺便翻译了这些(备份) 举报  打印  推荐  IE收藏夹 
       本主题类别: 样式表技术(XSL, XSLT, XSL-FO, CSS)    
     highshow 帅哥哟,离线,有人找我吗?
      
      
      等级:大一(猛啃高等数学)
      文章:16
      积分:135
      门派:XML.ORG.CN
      注册:2004/11/21

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给highshow发送一个短消息 把highshow加入好友 查看highshow的个人资料 搜索highshow在『 其他W3C规范 』的所有贴子 引用回复这个贴子 回复这个贴子 查看highshow的博客楼主
    发贴心情 最近用XSLT比较多,直接在看W3C的规范,顺便翻译了这些(备份)

    中国的文学界提出过这样的概念:作者意图,文本意图,读者意图。......作为一个规范,也是如此。这里只是奉上我的“读者意图”,如有和“作者意图”或“文本意图”相冲突的,诚肯大家指正。本人只是当作为一个提高英语翻译水平的锻炼,再者,本人有一个习惯,就是E文虽然看得懂,可就是看了就忘,可能是本人的记忆介质还只是中文的缘故吧,这里也算是帮助自已尽量记住一些东西吧:
         
    Abstract
    This specification defines the syntax and semantics of XSLT, which is a language for transforming XML documents into other XML documents.
    摘要
    本规范定义了XSLT的语法和语义,XSLT是一种用于将一个XML文档转换成另一个XML文档的语言。

    XSLT is designed for use as part of XSL, which is a stylesheet language for XML. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary.
    XSLT被设计成可供XSL使用的一部分,它作为XML的一种样式单语言。除XSLT外,XSL还包含了一套XML形式的格式化词汇表。XSL使用XSLT来描述一个文档如何转化为另一个目标文档,该目标文档使用XSL所提供的格式化词汇表来描述其格式,这样XSL就能指定一个XML文档所具有的格式。

    XSLT is also designed to be used independently of XSL. However, XSLT is not intended as a completely general-purpose XML transformation language. Rather it is designed primarily for the kinds of transformations that are needed when XSLT is used as part of XSL.
    XSLT还设计成可独立于XSL而被使用。然而,XSLT并不打算设计成作为一个具有完全通用意图的XML转换语言。确切的说,它最初只是设计成处理XSL所需要的那一类转换,作为XSL的一部分而被使用。

    1 Introduction
    XSLT namespace:“XSLT命名空间”
    Thus this specification is a definition of the syntax and semantics of the XSLT namespace。A transformation in the XSLT language is expressed as a well-formed XML document [XML] conforming to the Namespaces in XML Recommendation [XML Names], which may include both elements that are defined by XSLT and elements that are not defined by XSLT. XSLT-defined elements are distinguished by belonging to a specific XML namespace (see [2.1 XSLT Namespace]), which is referred to in this specification as the XSLT namespace. Thus this specification is a definition of the syntax and semantics of the XSLT namespace.
    本文档定义了“XSLT命名空间”的语法和语义。XSLT语言中的转换被表述成结构良好的XML文档,所以遵循XML标准中的命名空间,有可能同时既包含XSLT中定义的元素和XSLT中没有定义的。XSLT中定义的元素可以很容易地区分出来,因为它们都属于一个特定的XML命名空间(参见[2.1 XSLT Namespace]),在本规范中被称作XSLT命名空间。因些本规范是一个XSLT命名空间的语法和语义的定义。

    A transformation expressed in XSLT describes rules for transforming a source tree into a result tree.The transformation is achieved by associating patterns with templates. A pattern is matched against elements in the source tree. A template is instantiated to create part of the result tree. The result tree is separate from the source tree. The structure of the result tree can be completely different from the structure of the source tree. In constructing the result tree, elements from the source tree can be filtered and reordered, and arbitrary structure can be added.
    用XSLT表述的转换描述的是从“源树”到“结果树”的转换规则。通过将模式(patterns)与模板(templates)相结合来达到转换的目的。模式(pattern)用于匹配“源树”中的元素。实例化的模板(template)用于构造出“结果树”的某个部分。“结果树”与“源树”是相分离的。“结果树”的结构可以完全不同“源树”的结构。在构造“结果树”的过程中,来自于“源树”的元素可以被任意地过滤、重组,以及添加任何的结构。

    A transformation expressed in XSLT is called a stylesheet. This is because, in the case when XSLT is transforming into the XSL formatting vocabulary, the transformation functions as a stylesheet.
    用XSLT表述的转换被称作样式单(stylesheet)。这是因为,当XSLT用作“转化为XSL格式”意义的词汇时,转化起到了样式单(stylesheet)的作用。

    This document does not specify how an XSLT stylesheet is associated with an XML document. It is recommended that XSL processors support the mechanism described in [XML Stylesheet]. When this or any other mechanism yields a sequence of more than one XSLT stylesheet to be applied simultaneously to a XML document, then the effect should be the same as applying a single stylesheet that imports each member of the sequence in order (see [2.6.2 Stylesheet Import]).
    本文档并不说明一个XSLT样式单是如何与一个XML文档相联系的。它只是建议性的规定一个XSL处理器(XSL processors)必须支持[XML Stylesheet]中所描述的机制。

    A stylesheet contains a set of template rules. A template rule has two parts: a pattern which is matched against nodes in the source tree and a template which can be instantiated to form part of the result tree. This allows a stylesheet to be applicable to a wide class of documents that have similar source tree structures.
    一个样式单通常包含一套模板规则(构成一集合)。每个模板规则由两部分构成:模式,用于匹配“源树”中的结点;模板,可以被实例化,实例化的结果是生成“结果树中的某个部分”。(用于构造出“结果树”的某个部分)。这会使得一个样式单能够广泛适用于一类具有相似“源树结构”的文档。

    A template is instantiated for a particular source element to create part of the result tree. A template can contain elements that specify literal result element structure. A template can also contain elements from the XSLT namespace that are instructions for creating result tree fragments. When a template is instantiated, each instruction is executed and replaced by the result tree fragment that it creates.
    一个模板(会因)对应于特定的“源树中的某个元素”而被实例化,实例化的结果是生成“结果树中的某个部分”。(用来构造“结果树”的某个部分)。一个模板中的某些元素可以用于精确地(逐字地)指定“结果元素”的结构,而模板中来自于XSLT命名空间的某些元素还可以是用于创建“结果树片断”的指令。当一个模板被实例化时,每条指令会执行并被它所创建的“结果树片断”所替代。

    Instructions can select and process descendant source elements. Processing a descendant element creates a result tree fragment by finding the applicable template rule and instantiating its template. Note that elements are only processed when they have been selected by the execution of an instruction. The result tree is constructed by finding the template rule for the root node and instantiating its template.
    指令可用于选择并处理“子孙源树节点”。通过寻找可用的模板规则并实例化它的模板来处理一个“子孙元素”,结果会产生一个“结果树片断”。注意,只有当元素被执行的指令所选中时才会被处理。“结果树”是通过为根节点寻找模板规则并实例化其模板来构建出来的。

    In the process of finding the applicable template rule, more than one template rule may have a pattern that matches a given element. However, only one template rule will be applied. The method for deciding which template rule to apply is described in [5.5 Conflict Resolution for Template Rules].
    在寻找可用模板规则的过程中,可能会有多于一个的模板规则其模式能匹配到给定的一个元素。然而,只有一个模板规则会被应用。决定哪个模板规则会被应用的方法在[5.5 Conflict Resolution for Template Rules]中会被描述。

    A single template by itself has considerable power: it can create structures of arbitrary complexity; it can pull string values out of arbitrary locations in the source tree; it can generate structures that are repeated according to the occurrence of elements in the source tree. For simple transformations where the structure of the result tree is independent of the structure of the source tree, a stylesheet can often consist of only a single template, which functions as a template for the complete result tree. Transformations on XML documents that represent data are often of this kind (see [D.2 Data Example]). XSLT allows a simplified syntax for such stylesheets (see [2.3 Literal Result Element as Stylesheet]).
    (一个单独的)单单一个模板本身就具有惊人的能力:它通够创建任意复杂的结构;它能够提取出“源树”中任意位置的字符串值;它能够根据“源树”中某元素的多次出现来相应地重复产生某个结构。对某些简单的转换如“结果树”的结构独立于“源树”的结构,样式单通常仅由一个单独的模板所构成,起到匹配整个“结果树”模板的作用。对单独描述数据的XML文档所应用的转换通常是属于这类的。XSLT为这类样式单提供了简化的语法(详见[2.3 Literal Result Element as Stylesheet])

    When a template is instantiated, it is always instantiated with respect to a current node and a current node list. The current node is always a member of the current node list. Many operations in XSLT are relative to the current node. Only a few instructions change the current node list or the current node (see [5 Template Rules] and [8 Repetition]); during the instantiation of one of these instructions, the current node list changes to a new list of nodes and each member of this new list becomes the current node in turn; after the instantiation of the instruction is complete, the current node and current node list revert to what they were before the instruction was instantiated.
    当一个模板被实例化时,它通常是相对于一个当前节点和一个当前节点list而被实例化。而该当前节点通常是当前节点list的一个成员。XSLT的很多操作是相对于当前节点的。只有少数指令会改变当前节点list或当前节点(参见see [5 Template Rules] and [8 Repetition]);当这些指令中的某个被实例化时,当前节点list会变成新的节点list并且该新list的每个成员会轮流变成当前节点(在这些指令之一的实例化过程中,当前节点列表会更新为新的节点列表,此新列表中的每个成员又会轮流变成当前节点。);在这些指令的实例化完成后,当前节点和当前节点list会恢复到指令被实例化前他们的情形。

    XSLT makes use of the expression language defined by [XPath] for selecting elements for processing, for conditional processing and for generating text.
    XSLT使用Xpath所定义的表达式语言来选择要处理的节点,进行条件处理和产生文本。

    XSLT provides two "hooks" for extending the language, one hook for extending the set of instruction elements used in templates and one hook for extending the set of functions used in XPath expressions. These hooks are both based on XML namespaces. This version of XSLT does not define a mechanism for implementing the hooks. See [14 Extensions].
    XSLT提供了两种用于扩展的“hook”,一种是用来扩展在模板中使用的指令集(set of instruction elements);另一种是用来扩展在XPath表达式中使用的函数集。两种“hook”都是基于XML命名空间的。该版本的XSLT没有定义实现hook的机制,见[14 Extensions]。

    NOTE:The XSL WG intends to define such a mechanism in a future version of this specification or in a separate specification.
    注意:XSL工作小组打算在本规范的将来版本中定义出这样一套机制来,或者单独在另一个规范中定义。

    The element syntax summary notation used to describe the syntax of XSLT-defined elements is described in [18 Notation].
    [18 Notation]里描述的元素语法概要符号被用来描述XSLT中定义的元素的语法。

    The MIME media types text/xml and application/xml [RFC2376] should be used for XSLT stylesheets. It is possible that a media type will be registered specifically for XSLT stylesheets; if and when it is, that media type may also be used.
    MIME媒体类型“text/xml”和“application/xml”必须用于XSLT样式单。有可能会专门为XSLT样式单注册一个媒体类型。如果是这样,该媒体类型会被使用。

    2 Stylesheet Structure
    2.1 XSLT Namespace
    “命名空间URI”:每一个命名空间都有一个URI与之相对应。
    XSLT命名空间的URI:
    The XSLT namespace has the URI http://www.w3.org/1999/XSL/Transform
    “XSLT命名空间”拥用的URI:http://www.w3.org/1999/XSL/Transform

    The 1999 in the URI indicates the year in which the URI was allocated by the W3C. It does not indicate the version of XSLT being used, which is specified by attributes
    URI中的1999表明URI被W3C分配的年代时间,并不用来指明本样式单所采用的版本号,版本号会有专门的属性来指明。

    Elements from the XSLT namespace are recognized only in the stylesheet not in the source document.
    XSLT命名空间中的元素只有在样式单中时才会被识别,在源数据文档中不被识别。(xslt文档必须单独成为一个文件?)

    Vendors must not extend the XSLT namespace with additional elements or attributes.
    不能在“XSLT命名空间”中扩展自已的元素和属性。

    Instead, any extension must be in a separate namespace.
    然而,任何扩展都必须在一个单独的命名空间中进行。

    Any namespace that is used for additional instruction elements must be identified by means of the extension element mechanism specified in [14.1 Extension Elements].
    任何扩展必须采用14.1 Extension Elements中规定的扩展机制。

    This specification uses a prefix of xsl: for referring to elements in the XSLT namespace. However, XSLT stylesheets are free to use any prefix, provided that there is a namespace declaration that binds the prefix to the URI of the XSLT namespace.
    本规范采用“xsl:”名字的前缀来引用“XSLT命名空间”中的元素。然而,xslt一个样式单可以使用任何名字的前缀,只要有一个“命名空间申明”(namespace declaration)用于将该前缀的名字绑定到“XSLT命名空间”的URI上。

    An element from the XSLT namespace may have any attribute not from the XSLT namespace, provided that the expanded-name of the attribute has a non-null namespace URI.
    来自于“XSLT命名空间”的元素可能会拥用来自于“XSLT命名空间”之外的属性(扩展属性)。只要该扩展属性的名字expanded-name拥用一个非空的“命名空间URI”。

    The presence of such attributes must not change the behavior of XSLT elements and functions defined in this document. Thus, an XSLT processor is always free to ignore such attributes, and must ignore such attributes without giving an error if it does not recognize the namespace URI. Such attributes can provide, for example, unique identifiers, optimization hints, or documentation.
    这些属性的出现,不会改变本文档中所定义的XSLT元素的行为和一些功能。因此, XSLT处理器(XSLT processor)通常是随意地忽略这些属性,而且必须是在不给出任何错误的情况下忽略掉这些属性,哪怕它识别不了属性所对应的命名空间URI。这些属性通常能提供诸如,惟一标识符、优化提示、文档生成……的功能。

    It is an error for an element from the XSLT namespace to have attributes with expanded-names that have null namespace URIs (i.e. attributes with unprefixed names) other than attributes defined for the element in this document.
    假如一个XSLT元素拥用一个扩展属性(该属性不是本文档中为该元素定义的),而该属性的名字却不拥有一个非空的命名空间URI(例如:属性的名字没有任何前缀)(拥用空的命名空间URI),这将被认为是一种错误。

    NOTE:The conventions used for the names of XSLT elements, attributes and functions are that names are all lower-case, use hyphens to separate words, and use abbreviations only if they already appear in the syntax of a related language such as XML or HTML.
    注意:XSLT元素、属性、功能,取名时采用的惯例为:名字都使用小写,用连词符号“-”来分隔单词,只有在相关语言如XML或HTML中出现过的才采用简写形式。

    [此贴子已经被作者于2006-7-18 14:46:35编辑过]

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2006/7/18 12:07:00
     
     zhangkewang 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:65
      门派:XML.ORG.CN
      注册:2007/1/9

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给zhangkewang发送一个短消息 把zhangkewang加入好友 查看zhangkewang的个人资料 搜索zhangkewang在『 其他W3C规范 』的所有贴子 引用回复这个贴子 回复这个贴子 查看zhangkewang的博客2
    发贴心情 
    辛苦,就是。。。
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/1/15 11:15:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 其他W3C规范 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/3/28 18:30:11

    本主题贴数2,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    93.750ms