XML Final section 6.3
An XML document contains the root element named books, which has a single child element named book. Each book element has two child elements named title and author. Using the XSLT's for-each element, sort the book elements in alphabetical order based on the title. - Answer- xsl:for-each select="/books/book" xsl:sort select="title" / /xsl:for-each By default, does the xsl:sort element sort items numerically or alphabetically? - Answer- Alphabetically The book element has a single attribute named category. The value of category can be either fiction or nonfiction. Write an if construction that displays the book title only if it is a nonfiction book. - Answer- xsl:if test="@category = 'Non-fiction'" xsl:value-of select="title" / /xsl:if Use a choose construction that displays book titles in an h3 heading if they are fiction and an h2 heading if otherwise. - Answer- xsl:choose xsl:when test="@category = 'Fiction'" h3xsl:value-of select="title" //h3 /xsl:when
Document information
- Uploaded on
- August 29, 2023
- Number of pages
- 2
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers