XPathAndXSLT

Pēdējais mainījis Administrator 2011-06-06 17:32

XPath and XSLT

Using XPath 1.0 and XSLT transformations

Jauns jautājums:

Prasmes

  1. XPath 1.0 for Addressing Nodes Write absolute and relative XPath expressions to various kinds of XML nodes and nodesets
  2. XPath 1.0 Functions Use XPath functions
  3. XSLT Processing Issues Understand behavior of compliant XSLT processors
  4. XSLT 1.0 Constructs Apply various XSLT constructs

1. XPath 1.0 for Addressing Nodes

  • 1001
    /descendant-or-self::contacts/contact[attribute::firstname='Fred']
    Which one of the following XPath queries is equivalent to the sample code above?
    1. /self::contacts/contact[attribute::firstname='Fred']
    2. //contacts/contact/@firstname='Fred'
    3. //contact[@firstname='Fred']
    4. //contacts/contact[@firstname='Fred']
    5. /contacts/contact[@firstname='Fred']
  • 1002
    <?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>
    Referring to the above sample code, what is the correct Xpath to the first CD's title?
    1. /cds:collection/cds:cds/cds:cd[1]/cds:title
    2. /collection/cds/cd[1]/title
    3. /collection/cds/cds:cd[1]/cds:title
    4. /collection/cds:cds/cds:cd[1]/cds:title
    5. /collection/cds:cds/cds:cd[1]/title
  • 1003
    parent::node()
    The above Xpath reference is symbolized by which one of the following characters?

    1. The "//" characters
    2. The "*" character
    3. The "." characters
    4. The ".." characters
    5. The "@" character

2. XPath 1.0 Functions

  • 2002
    <xsl:value-of select="floor(number)"/>
    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?
    1. -7
    2. -6.1
    3. -6
    4. 6
    5. 7

3. XSLT Processing Issues

  • 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?
    1. These processors leave tags such as "<br/>" unclosed to comply with traditional HTML conventions.
    2. These processors add "<!--" and "-->" tags around the entire output text so that older browsers will not try to render it.
    3. The processors are unable to process well-formed XSL stylesheets.
    4. The output from these processors cannot be altered with CSS.
    5. The output from these processors can always undergo a second XSLT transformation if desired.
  • 3002
    What do standard XSLT processors do with comments found between "<!--" and "-->" tags in a source document?
    1. Pass them on to the output file without changing them.
    2. Discard them.
    3. Remove the "<!--" and "-->" delimiters so they appear as plain text in the output file.
    4. Embed them in special "<xml:comment>" and "</xml:comment>" tags.
    5. Change the "<!--" and "-->" tags to "<?" and "?>".
  • 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?
    1. These processors leave tags such as "<BR>" unclosed to comply with traditional HTML conventions.
    2. These processors add "<!--" and "-->" tags around the entire output text so that older browsers will not try to render it.
    3. The processors are unable to process well-formed XSL stylesheets.
    4. The output from these processors cannot be altered with CSS.
    5. The output from these processors can always undergo a second XSLT transformation if desired.

4. XSLT 1.0 Constructs

  • 4001
    <?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>
    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?
    1. <xsl:value-of select="/library/author/book/title> 
        <br/> 
      </xsl:value-of>
    2. <xsl:for-each select="/library/author/book/title"> 
        <xsl:value-of select="."/><br/> 
      </xsl:for-each>
    3. <xsl:for-each select="/library/author/book/title"> 
        <br/> 
      </xsl:for-each>
    4. <xsl:for-each> 
        <xsl:value-of select="/library/author/book/title"/><br/> 
      </xsl:for-each>
    5. <xsl:while test="/library/author/book/title[. = '']"> 
        <xsl:value-of select="/library/author/book/title"/><br/> 
      </xsl:while>
  • 4002
    Which one of the following XSLT elements can be used as a top-level element?
    1. The "xsl:apply-imports" element
    2. The "xsl:choose" element
    3. The "xsl:apply-templates" element
    4. The "xsl:attribute-set" element
    5. The "xsl:copy-of" element

Citi jautājumi

Tagi:
Izveidojis Kalvis Apsītis 2008-01-01 21:10
    
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 6.4 - Documentation