XPathAndXSLT

Pēdējais mainījis superadmin 2018-01-12 20:24

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

    1. XPath 1.0 Functions

    Use XPath functions

    1. XSLT Processing Issues

    Understand behavior of compliant XSLT processors

    1. XSLT 1.0 Constructs

    Apply various XSLT constructs

1. XPath 1.0 for Addressing Nodes

  • 1001

    {code}
    /descendant-or-self::contacts/contact[attribute::firstname='Fred']
    {code} Which one of the following XPath queries is equivalent to the sample code above?

    1. {code}
      /self::contacts/contact[attribute::firstname='Fred']
      {code}

    2. {code}
      contacts/contact/@firstname='Fred'
      {code}

    3. {code}
      contact[@firstname='Fred']
      {code}

    4. {code}
      contacts/contact[@firstname='Fred']
      {code}

    5. {code}
      /contacts/contact[@firstname='Fred']
      {code}

  • 1002

    {code:xml}
    <?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>
    {code} Referring to the above sample code, what is the correct Xpath to the first CD's title? 

    1. {code}
      /cds:collection/cds:cds/cds:cd[1]/cds:title
      {code}

    2. {code}
      /collection/cds/cd[1]/title
      {code}

    3. {code}
      /collection/cds/cds:cd[1]/cds:title
      {code}

    4. {code}
      /collection/cds:cds/cds:cd[1]/cds:title
      {code}

    5. {code}
      /collection/cds:cds/cds:cd[1]/title
      {code}

  • 1003

    {code}
    parent::node()
    {code} 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

    {code:xml}
    <xsl:value-of select="floor(number)"/>
    {code} 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 "<tt>&lt;br/></tt>" unclosed to comply with traditional HTML conventions.

    2. These processors add "<tt>&lt;!</tt>" and "<tt>&gt;</tt>" 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 "<tt>&lt;!&#x2D;-</tt>" and "<tt>&#x2D;-&gt;</tt>" tags in a source document?

    1. Pass them on to the output file without changing them.

    2. Discard them.

    3. Remove the "<tt>&lt;!&#x2D;-</tt>" and "<tt>&#x2D;-&gt;</tt>" delimiters so they appear as plain text in the output file.

    4. Embed them in special "<tt>&lt;xml:comment></tt>" and "<tt>&lt;/xml:comment></tt>" tags.

    5. Change the "<tt>&lt;!&#x2D;-</tt>" and "<tt>&#x2D;-&gt;</tt>" tags to "<tt>&lt;?</tt>" and "<tt>?&gt;</tt>".

  • 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 "<tt>&lt;BR></tt>" unclosed to comply with traditional HTML conventions.

    2. These processors add "<tt>&lt;!\-\-</tt>" and "<tt>\-\-></tt>" 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

    {code:xml}
    <?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>
    {code} 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. {code:xml}
      <xsl:value-of select="/library/author/book/title>
        <br/>
      </xsl:value-of>
      {code}

    2. {code:xml}
      <xsl:for-each select="/library/author/book/title">
        <xsl:value-of select="."/><br/>
      </xsl:for-each>
      {code}

    3. {code:xml}
      <xsl:for-each select="/library/author/book/title">
        <br/>
      </xsl:for-each>
      {code}

    4. {code:xml}
      <xsl:for-each>
        <xsl:value-of select="/library/author/book/title"/><br/>
      </xsl:for-each>
      {code}

    5. {code:xml}
      <xsl:while test="/library/author/book/title[. = '']">
        <xsl:value-of select="/library/author/book/title"/><br/>
      </xsl:while>
      {code}

  • 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