tailieunhanh - Learning XML phần 7

Cấu trúc Bày tỏ với Templates Trong CSS, chúng tôi chỉ định phong cách bằng cách thiết lập các thông số trong các quy tắc. Đó là tốt cho đầu ra phù hợp với cấu trúc của tài liệu đầu vào, nhưng đối với XSLT, nó là không đủ, như các cây kết quả có thể được cấu trúc hoàn toàn khác nhau từ nguồn. | Learning XML Expressing Structure with Templates In CSS we assign style by setting parameters in rules. That s fine for output that matches the structure of the input document but for XSLT it isn t enough as the result tree might be structured completely differently from the source. The easiest way to represent a subtree s structure is by simply writing out the subtree as it would appear. This literal model is called a template so we call rules in a transformation template rules. Here s an example of a template rule xsl template match html head title My first template rule title head body h1 H lo world h1 body html xsl template Its output is an HTML file html head title My first template rule title head body h1 H lo world h1 body html The rule is an XML element called template whose contents are the elements and data that will form the result subtree. In this case the result is a complete HTML file. This example is not incredibly interesting as it uses none of the original data or structure from the source tree. In fact you could apply this rule to any document and the output would always be the same HTML file. Nevertheless it is a perfectly acceptable template rule in XSLT. Notice the match attribute in the template element. This attribute is the part of the rule that zeroes in on the appropriate level of a source tree a process called selection. Here the attribute selects the root node that abstract point just above the document element. This is where transformation starts and therefore our example rule will be the first rule executed in an XSLT stylesheet. Since the rule doesn t allow processing to continue past the root node there are no references to the children of this node it effectively blocks all other rules. The transformation not only begins with this rule but ends here as well. A more useful template rule might include as content one or more of the special elements apply-templates or value-of which transmit the processing to another level of the

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.