tailieunhanh - programming XML by Example phần 7

Hình 9,5 và 9,6 minh họa sự khác biệt giữa hai các DTD. Hình là cấu trúc được tạo ra cho đến nay nó là một cấu trúc phức tạp với nhiều cấp độ của tổ. Hình 9,6, mặt khác, có một cấu trúc : Cấu trúc mặc định Hình 9,6: | Writing with Flexibility in Mind 303 Figures and illustrate the difference between the two DTDs. Figure is the structure created so far it is a complex structure with several levels of nesting. Figure on the other hand has a flat structure. Figure The default structure Figure The new structure Figures and show the difference when selecting one or the other output format in the browser. OUTPUT Figure Default output format Figure New output format Calling XSLT o 11 The major difference between this application and the previous one is the exportProductO function. exportProductO calls makeXMLO to generate the XML document. Depending on the user choice it may apply an XSLT style EXAMPLE sheet to the result. function exportProduct form xml xslt var selected format selected .value if format default makeXML 304 Chapter 9 Writing XML else var xmlDoc makeXMLO false passes an XML string to the parser xmlDoc Unfortunately the DOM standard does not specify how to apply an XSLT style sheet to a document. Again you can use a browser-specific extension. For Internet Explorer the XSL processor is called by the transformNode method. The XSLT style sheet was loaded in a separate XML island. xml id xml xml xml id xslt src xml Which Structure for the Document If your application supports several DTDs you may wonder which one to use as the default DTD. Experience shows that it pays to be dumb when designing this default DTD. I like to define a DTD that is very similar to my object structure. So if the application has Product and Price objects I create two elements product and price. There are two main advantages to designing a DTD that is close to the internal data structure It is easy to generate the XML document. The resulting document is as expressive as the internal data structure. XSLT Versus .

TỪ KHÓA LIÊN QUAN