tailieunhanh - XML Step by Step- P25

XML Step by Step- P25:Extensible Markup Language, or XML, is currently the most promising language for storing and exchanging information on the World Wide Web. Although Hypertext Markup Language (HTML) is presently the most common language used to create Web pages, HTML has a limited capacity for storing information. In contrast, because XML allows you to create your own elements, attributes, and document structure, you can use it to describe virtually any kind of information from a simple recipe to a complex database | Chapter 12 Displaying XML Documents Using XSLT Style Sheets 451 xsl template match BOOK -- display current BOOK element. -- xsl template Although the filter clause could be added to the match attribute of the xsl template element rather than the select attribute of the xsl apply-templates element the browser would then apply a template to all BOOK elements. For the BOOK elements that don t match the filter criteria in the xsl template element the non-trade paperback books the browser would use its built-in template which would display all the BOOK elements text creating extraneous output unless you explicitly defined another template to match the non-trade paperback books . Accessing XML Attributes Technically in XSLT an attribute is not considered to be a child of the element that contains it. However in a location path or in a filter clause within a location path you can reference an attribute as if it were a child of the element that contains it by entering the attribute name prefaced with the at sign @ which indicates that the name refers to an attribute rather than to an element. For example the location path in the following start-tag selects every BOOK element with an attribute named InStock that has the value yes. In other words it selects only the books that are in stock xsl for-each select INVENTORY BOOK @InStock yes And the location path in the following xsl for-each start-tag selects every BOOK element that has an attribute named InStock regardless of the attribute s value xsl for-each select INVENTORY BOOK @InStock You can use the xsl value-of element to extract the value of an attribute in the same way you use it to extract the text content of an element. For example the following xsl value-of element outputs the value of the Born attribute belonging to the AUTHOR element xsl value-of select AUTHOR @Born The location path in the following xsl for-each start-tag selects every attribute belonging to the AUTHOR element xsl for-each select AUTHOR @ Using

TỪ KHÓA LIÊN QUAN