Home > Backend Development > XML/RSS Tutorial > XML introductory tutorial: XSLT-XML/XSLT code examples

XML introductory tutorial: XSLT-XML/XSLT code examples

黄舟
Release: 2017-03-11 17:29:34
Original
1691 people have browsed it

XSLT is part of XSL, which is an application of XML that specifies the rules for converting an XML document into another XML document. An XSLT document is an XML document and a style sheet, which contains a series of templates. The XSLT processor compares the elements in the input XML document with the templates in the style sheet. If they match, the template's content is ​                     XSLT is a part of XSL, which is an application of XML that specifies the rules for converting one XML document into another XML document. An XSLT document is an XML document and a style sheet, which contains a series of templates. The XSLT processor compares elements in the input XML document with templates in the style sheet, and if they match, writes the contents of the template into an output tree. Finish
XSLT is part of XSL. It is an application of XML that specifies the rules for converting an XML document into another XML document. An XSLT document is an XML document and a style sheet, which contains a series of templates. The XSLT processor compares elements in the input XML document with templates in the style sheet, and if they match, writes the contents of the template into an output tree. After completing the processing, serialize the output tree into an XML document or
other format document, such as HTML or rtf. Several key terms of XSLT

  • Source tree, the tree of elements and element content in the original document. ​​​​​​​

  • The result tree is the tree of elements and element content in the document after conversion. ​ ​ ​ ​

  • Template rules, the basis of XSLT style sheets, are divided into two parts:

    mode and template. The entire xsl:template element.                                                                                                                                                                           

  • # Pattern, represents the set of conditions for elements in the source tree to match pattern rules. The value of match in xsl:template.                

  • Template, indicating the part of the result tree to be instantiated when applying template rules. The content in the xsl:template element.

  • XSLT

    defines 35 elements, divided into three categories:

  • Two root elements

    • xsl:stylesheet root element, XSLT is also an XML document, and the root element of the document is xsl:stylesheet. XSLT elements all belong to the namespace xmlns:xsl="http://www.w3.org/1999/XSL/Trans

      form", so all XSLT elements have the xsl prefix. A minimized XSLT document:

    • <?xml version="1.0"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      </xsl:stylesheet>
      Copy after login
    • xsl:transform element, the same effect as above.

    • 13 top-level elements, which can be directly used as child elements of the root element, including:

      • xsl:apply-imports    
        xsl:attribute-set    
        xsl:decimal-format    
        xsl:import    
        xsl:include    
        xsl:key    
        xsl:namespace-alias    
        xsl:output    
        xsl:param    
        xsl:preserve-space    
        xsl:strip-space    
        xsl:template模板元素,用于匹配XML文档中的元素。如:<xsl:template match="person">,
        匹配XML文档中的person元素。    
        xsl:variable
        Copy after login

      • 20 directive elements

        • xsl:apply-imports    
          xsl:apply-template应用模板元素,用于显示指定的元素值(内容)。
          如:<xsl:apply-template select="name">,显示name元素的值。    
          xsl:attribute    
          xsl:call-template    
          xsl:choose    
          xsl:comment    
          xsl:copy    
          xsl:copy-of    
          xsl:element    
          xsl:fallback    
          xsl:for-each    
          xsl:if    
          xsl:message    
          xsl:number    
          xsl:otherwise    
          xsl:processing-instruction    
          xsl:text    
          xsl:value-of选择元素,用于计算元素的值(内容)。
          如:<xsl:value-of select="name">,获得XML文档中name元素的值(内容)。    
          xsl:variable    
          xsl:when    
          XSLT函数
          Copy after login

      The above is the detailed content of XML introductory tutorial: XSLT-XML/XSLT code examples. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template