Flashcards on XSLT and XPath for XML Transformation

XSLT and XPath for XML Transformation: A Student Guide

1 / 21

What is considered a "Tree of Nodes" in XPath?

In XPath, XML is viewed as a tree of nodes, which includes elements, attributes, text, comments, namespaces, processing instructions, and the document

Tap to flip · Swipe to navigate

XPath and XSLT

21 cards

Card 1

Question: What is considered a "Tree of Nodes" in XPath?

Answer: In XPath, XML is viewed as a tree of nodes, which includes elements, attributes, text, comments, namespaces, processing instructions, and the document

Card 2

Question: What is the meaning of the expression "/root_element/next/level" in XPath?

Answer: This expression starts addressing from the root element and navigates sequentially through its children according to the specified path.

Card 3

Question: What is the difference between "/element" and "//element" in XPath?

Answer: "/element" selects elements relative to the root; "//element" finds elements anywhere in the document (from the current position, regardless of depth)

Card 4

Question: In XPath, what do "." and ".." signify?

Answer: "." refers to the current node, and ".." refers to the parent node of the current node.

Card 5

Question: How do you select an attribute in XPath?

Answer: You use the '@' symbol. For example, `student/@id` selects the 'id' attribute of the 'student' element.

Card 6

Question: What does the expression "/bookstore/book[last()]" do?

Answer: It selects the last 'book' element that is a child of the 'bookstore' element.

Card 7

Question: How do you select 'title' elements that have a 'lang' attribute in XPath?

Answer: You use `//title[@lang]` — this selects all 'title' elements that possess a 'lang' attribute.

Card 8

Question: How do you select 'title' elements where the 'lang' attribute is equal to 'eng'?

Answer: You use `//title[@lang='eng']`.

Card 9

Question: What does the expression "/bookstore/book[price>35.00]/title" do?

Answer: It selects the 'title' elements of all 'book' elements within the 'bookstore' whose child 'price' element has a value greater than 35.00.

Card 10

Question: How do you select the first 'student' element within a `<university>` element using XPath?

Answer: You use `/university/student[1]`.