xslt cookbook phần 4

Chú ý rằng chúng tôi đã nhận xét ra các kiểm tra cho các kích cỡ không đồng đều bởi vì thử nghiệm đó là không hợp lệ trong sự hiện diện của bản sao. Ví dụ, một bộ có thể có ba lần xuất hiện của một phần tử với chuỗi giá trị foo, trong khi có một yếu tố duy nhất foo. | xsl import href xsl param name collapse xsl variable name collapse-test select concat collapse xsl template match mode name xsl if test not ancestor contains collapse-test concat local-name . xsl apply-imports xsl if xsl template xsl template match mode value xsl if test not ancestor contains collapse-test concat local-name . xsl apply-imports xsl if xsl template xsl template match mode line-break xsl if test not ancestor contains collapse-test concat local-name . xsl apply-imports xsl if xsl template xsl template match mode indent xsl choose xsl when test self contains collapse-test concat local-name . xsl for-each select ancestor xsl text xsl text xsl for-each xsl text x- xsl text xsl when xsl when test ancestor contains collapse-test concat local- name . xsl otherwise xsl apply-imports xsl otherwise xsl choose xsl template xsl stylesheet Example 5-34. Output with collapse Employee PayPeriod o- ExpenseReport x- Employee x- PayPeriod o- Expenses o- Expense - Date 12 20 01 - Account 12345 Desc Goofing off instead of going to confrence. - Lodging Transport Fuel 0 - Meals - Phone 10 0 - Entertainment - other o- Expense - Date 12 20 01 - Account 12345 Desc On the beach - Lodging Transport Fuel 0 - Meals - Phone 2 0 - Entertainment - other There is literally no end to the variety of custom tree formats you can create from overrides to the basic stylesheet. In object-oriented circles this technique is called the template-method pattern. It involves building the skeleton of an algorithm and allowing subclasses to redefine certain steps without changing the algorithm s structure. In the case of XSLT importing stylesheets take the place of subclasses. The power of this example does not stem from the fact that creating tree-like rendering is difficult it is not. Instead the power lies in the ability to reuse the example s structure while considering only the aspects you want to change. .

Bấm vào đây để xem trước nội dung
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG