ItemSet: XPath and XSLT
Using XPath 1.0 and XSLT transformationsSkills
- XPath 1.0 for Addressing Nodes
Write absolute and relative XPath expressions to various kinds of XML nodes and nodesets - XPath 1.0 Functions
Use XPath functions - XSLT Processing Issues
Understand behavior of compliant XSLT processors - XSLT 1.0 Constructs
Apply various XSLT constructs
1. XPath 1.0 for Addressing Nodes
- XPathAndXSLT_1001: Which one of the following XPath queries is equivalent to the sample code above?
/descendant-or-self::contacts/contact[attribute::firstname='Fred']
/self::contacts/contact[attribute::firstname='Fred']
//contacts/contact/@firstname='Fred'
//contact[@firstname='Fred']
//contacts/contact[@firstname='Fred']
/contacts/contact[@firstname='Fred']
- XPathAndXSLT_1002: Referring to the above sample code, what is the correct Xpath to the first CD's title?
<?xml version="1.0"?> <collection xmlns:cds="http://www.acmer.com/cds"> <fred name="fred"/> <cds:cds> <cds:cd> <cds:title>Rocking to the Twenties</cds:title> <cds:year>1925</cds:year> </cds:cd> <cds:cd> <cds:title>Rocking to the Thirties</cds:title> <cds:year>1935</cds:year> </cds:cd> </cds:cds> </collection>
/cds:collection/cds:cds/cds:cd[1]/cds:title
/collection/cds/cd[1]/title
/collection/cds/cds:cd[1]/cds:title
/collection/cds:cds/cds:cd[1]/cds:title
/collection/cds:cds/cds:cd[1]/title
- XPathAndXSLT_1003: The above Xpath reference is symbolized by which one of the following characters?
parent::node()
- The "//" characters
- The "*" character
- The "." characters
- The ".." characters
- The "@" character
2. XPath 1.0 Functions
- XPathAndXSLT_2002: Referring to the line of XSL sample code above, which one of the following lines is output if this code is used to transform an XML document in which the value of "number" is -6.1?
<xsl:value-of select="floor(number)"/>- -7
- -6.1
- -6
- 6
- 7
3. XSLT Processing Issues
- XPathAndXSLT_3001: Which one of the following statements is true about XSLT processors that intentionally output mal-formed XML when producing HTML in order to be more browser compatible?
- These processors leave tags such as "<br/>" unclosed to comply with traditional HTML conventions.
- These processors add "<!--" and "-->" tags around the entire output text so that older browsers will not try to render it.
- The processors are unable to process well-formed XSL stylesheets.
- The output from these processors cannot be altered with CSS.
- The output from these processors can always undergo a second XSLT transformation if desired.
- XPathAndXSLT_3002: What do standard XSLT processors do with comments found between "<!--" and "-->" tags in a source document?
- Pass them on to the output file without changing them.
- Discard them.
- Remove the "<!--" and "-->" delimiters so they appear as plain text in the output file.
- Embed them in special "<xml:comment>" and "</xml:comment>" tags.
- Change the "<!--" and "-->" tags to "<?" and "?>".
- XPathAndXSLT_3003: Which one of the following statements is true about XSLT processors that intentionally output mal-formed XML when producing HTML in order to be more browser compatible?
- These processors leave tags such as "<BR>" unclosed to comply with traditional HTML conventions.
- These processors add "<!--" and "-->" tags around the entire output text so that older browsers will not try to render it.
- The processors are unable to process well-formed XSL stylesheets.
- The output from these processors cannot be altered with CSS.
- The output from these processors can always undergo a second XSLT transformation if desired.
4. XSLT 1.0 Constructs
- XPathAndXSLT_4001: Using the above XML document, you are assigned to create a stylesheet that lists the title of each of the Shakespeare books in the library's inventory. Which one of the following XSL samples do you use in the stylesheet to produce this list in HTML?
<?xml version="1.0"?> <library> <author name="William Shakespeare"> <book> <title>Macbeth</title> <pages>236</pages> </book> <book> <title>Romeo and Juliet</title> <pages>209</pages> </book> <book> <title>Othello</title> <pages>311</pages> </book> </author> </library>
<xsl:value-of select="/library/author/book/title> <br/> </xsl:value-of>
<xsl:for-each select="/library/author/book/title"> <xsl:value-of select="."/><br/> </xsl:for-each>
<xsl:for-each select="/library/author/book/title"> <br/> </xsl:for-each>
<xsl:for-each> <xsl:value-of select="/library/author/book/title"/><br/> </xsl:for-each>
<xsl:while test="/library/author/book/title[. = '']"> <xsl:value-of select="/library/author/book/title"/><br/> </xsl:while>
- XPathAndXSLT_4002: Which one of the following XSLT elements can be used as a top-level element?
- The "xsl:apply-imports" element
- The "xsl:choose" element
- The "xsl:apply-templates" element
- The "xsl:attribute-set" element
- The "xsl:copy-of" element
Unclassified Questions
on 2008/01/02 23:48