xslt cookbook phần 6

Điều này sẽ đảm bảo rằng các bản sao được hạch toán đầy đủ trên mỗi đường đi qua đệ quy. Những thay đổi này làm cho tất cả các bài kiểm tra bình đẳng dựa trên giá trị văn bản đi ra chính xác, nhưng với chi phí thực hiện công việc bổ sung trên bộ rõ ràng là bất bình đẳng. | xsl stylesheet Two elements in this stylesheet make it work. The first is the xml - stylesheet processing instruction which tells the browser that the stylesheet associated with the document it loads is the very same document. You can refer to the same document as its stylesheet with href rather than specifying the name of the file which is helpful if you ever rename it. The second is the template that matches the xsl stylesheet element and redirects stylesheet processing to the embedded XML data. In this case the elements are in the http XSLTCookbook namespaces portfolio namespace. Discussion This recipe is somewhat of a trick to impress your friends. Intermixing content and styling in some ways goes against the spirit of the technology. However delivering just a single file can be convenient so you should not feel guilty about using this recipe if it suits your needs. The official way to achieve these results is to embed the stylesheet in the document rather than vice versa. See http TR xslt section-Embedding-Stylesheets for more details. However IE does not yet support embedded stylesheets so this trick gets around the problem. You can deliver content in this form without necessarily developing the content directly in this form. The following stylesheet merges a stylesheet and an XML file into the self-contained format. The only two criteria are that the XML must be in a namespace and the stylesheet should not begin processing at the root node -- -- xsl stylesheet version xmlns xsl http 1999 XSL Transform xmlns xso dummy -- Reuse the identity transform -- xsl import href . util -- This stylesheet will be generating styleshhet content so use xso as alias for xsl -- xsl namespace-alias stylesheet -prefix xso result-prefix xsl xsl output method xml version encoding UTF-8 indent yes xsl strip-space elements --Not a good idea to strip space from text nodes -- xsl preserve-space .