test de position XML

Test de Positionnement

Question

Select which of the following is incorrect as a method for using XSLT.

  1. Transform XML data into HTML for display in a web browser
  2. Output a portion of data extracted from source XML data in order to send XML data to another system
  3. Output data in CSV format (text format) in order to send XML data to a system that does not support XML
  4. Transform XML data into a zip format (compressed format) in order to send the data more efficiently
  • ( + )Solution
Question

Select which of the following is correct as an XSLT stylesheet notation.

  1. <?xml version="1.0" encoding="UTF-8"?>
    <stylesheet version="1.0">
     
     <template match="/">
      <html>
       <body>
         <h1>Welcome</h1>
         Hello<value-of select="UserList/User/Name" /> <br/>
       </body>
      </html>
     </template>
    </stylesheet>
  2. <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
     
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <html>
      <body>
        <h1>Welcome</h1>
        Hello<xsl:value-of select="UserList/User/Name" /><br/>
      </body>
     </html>
    </xsl:stylesheet>
  3. <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
     
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
      <html>
       <body>
         <h1>Welcome</h1>
         Hello<xsl:value-of select="UserList/User/Name" /><br>
       </body>
      </html>
     </xsl:template>
    </xsl:stylesheet>
  4. <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
     
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
      <html>
       <body>
         <h1>Welcome</h1>
         Hello<xsl:value-of select="UserList/User/Name" /><br/>
       </body>
      </html>
     </xsl:template>
    </xsl:stylesheet>
  • ( + )Solution
Question

Select which of the following is the correct XPath notation corresponding to (1), when you want to transform the following XML document into HTML using an XSLT stylesheet. Select all that apply.

[XML Document]
<?xml version="1.0" encoding="UTF-8"?>
<Snack>
  <Yesterday>
    <Fruit>Banana</Fruit>
  </Yesterday>
  <Today>
    <Fruit>Watermelon</Fruit>
  </Today>
  <Tomorrow>
    <Fruit>Melon</Fruit>
  </Tomorrow>
</Snack>

[XSL Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/">
    <html>
      <body>
        <h1>Snack</h1>
        <xsl:apply-templates select="Snack/Tomorrow"/>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Tomorrow">
      Snack will be<xsl:value-of select="     (1)     " /><br/>
  </xsl:template>
</xsl:stylesheet>

[HTML Document]
<html>
  <body>
    <h1>Snack</h1>
    Snack will be Melon<br>
  </body>
</html>

  1. /Snack/Tomorrow/Fruit
  2. Snack/Tomorrow/Fruit
  3. Tomorrow/Fruit
  4. Fruit
  • ( + )Solution
Question

Select which of the following is the appropriate transformation result when the following XML Document is transformed through the XSLT stylesheet.

[XML Document]
<?xml version="1.0" ?>
<ProductList>
  <Title>XML Series Commemorative Goods</Title>
    <Product>
      <ProductName>XML Pen</ProductName>
      <UnitPrice>200</UnitPrice>
    </Product>
</ProductList>

[XSLT Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates select="ProductList/Product"/>
        <xsl:apply-templates select="ProductList/Auxiliary"/>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="/ProductList/Product">
    - ProductName:<xsl:value-of select="ProductName" /><br/>
    - UnitPrice:<xsl:value-of select="UnitPrice" />$<br/>
  </xsl:template>
  <xsl:template match="ProductList/Product">
    § ProductName:<xsl:value-of select="ProductName" /><br/>
    § UnitPrice:<xsl:value-of select="UnitPrice" />USD<br/>
  </xsl:template>
  <xsl:template match="Auxiliary">
    Auxiliary:<br/>
    <xsl:value-of select="." /><br/>
  </xsl:template>
</xsl:stylesheet>

  1. <html>
      <body>
        - ProductName:XML Pen<br>
        - UnitPrice:200USD<br>
      </body>
    </html>
  2. <html>
      <body>
        § ProductName:XML Pen<br>
        § UnitPrice:200USD<br>
      </body>
    </html>
  3. <html>
      <body>
        - ProductName:XML Pen<br>
        - UnitPrice:200USD<br>
        Auxiliary:<br>
      </body>
    </html>
  4. <html>
      <body>
        § ProductName:XML Pen<br>
        § UnitPrice:200USD<br>
        Auxiliary:<br>
      </body>
    </html>
  • ( + )Solution
Question

Select which of the following is the correct XPath notation that applies to (1) for outputting "XML Pen" when the following XML Document is transformed by the XSLT Stylesheet.

[XML Document]
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="inventory.xsl"?>
<SalesChart>
  <Product Code="XML001">
    <ProductName>XML Pen</ProductName>
    <UnitPrice>150</UnitPrice>
    <Volume>20</Volume>
  </Product>
  <Product Code="XML002">
    <ProductName>Mousepad</ProductName>
    <UnitPrice>500</UnitPrice>
    <Volume>2</Volume>
  </Product>
</SalesChart>

[XSLT Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <body>
        <xsl:apply-templates select="

[  (1)  ]

        " />
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Product">
    <xsl:value-of select="ProductName" /><br/>
  </xsl:template>
</xsl:stylesheet>

  1. SalesChart/Product[Volume<5]
  2. SalesChart/Product[@Code=XML001]
  3. SalesChart/Product[UnitPrice* Volume>1500]
  4. SalesChart/Product[0]
  • ( + )Solution
Question

Which notation can correctly be placed in (1) below to produce the desired Transformation Result when the XSLT Stylesheet is used to transform the XML Document below?

[XML Document]
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="test03.xsl"?>
<ProductList>
  <Title>XML Series Commemorative Goods</Title>
  <Product>
    <ProductName>XML Pen</ProductName>
    <UnitPrice>200</UnitPrice>
    <Image>XMLMasterPen.jpg</Image>
  </Product>
</ProductList>

[XSLT Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <body>
        <h1><xsl:value-of select="ProductList/Title" /></h1>
        Featured Product<br/>
        <table border="1" width="400">
          <tr><th>Product Image</th>
          <th>ProductName</th><th>Price</th></tr>
          <xsl:apply-templates select="ProductList/Product"/>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="Product">
      <td>

[    (1)    ]

        </td>
        <td><xsl:value-of select="ProductName" /></td>
        <td><xsl:value-of select="UnitPrice" /></td>
    </tr>
  </xsl:template>
</xsl:stylesheet>

[Transformation Result]
<img src="XMLMasterPen.jpg">

  1. <img src="<xsl:value-of select='Image'/>" />
  2. <img src="string(Image)" />
  3. <img src="XPath(Image)" />
  4. <img src="{Image}" />
  • ( + )Solution
Question

Which of the following is incorrect with respect to XSLT functions?

  1. The xsl:if command includes a description of a template that is executed if the test attribute condition is "true"
  2. The xsl:for-each command allows repetitive processing for all nodes defined in the select attribute
  3. The xsl:choose command incorporates the processing of an xsl:else element when there are no "true" conditions
  4. The xsl:copy command only copies the current node
  • ( + )Solution
Question

Assume that the XSLT Stylesheet is applied to XML Document A, resulting in the output of XML Document B. Select the section of the XSLT stylesheet that correctly fits into (1) below.

[XML Document A]
<?xml version="1.0" ?>
<Product>
  <Orange UnitPrice="40"/>
</Product>

[XSLT Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <Fruit>
      <xsl:apply-templates select="/Product/Orange"/>
    </Fruit>
  </xsl:template>
  <xsl:template match="Orange">
      <Orange>

[    (1)    ]

      </Orange>
  </xsl:template>
</xsl:stylesheet>

[XML Document B]
<?xml version="1.0" ?>
<Fruit>
<Orange><UnitPrice>40</UnitPrice></Orange>
</Fruit>

A.
<xsl:attribute name="UnitPrice">
<xsl:value-of select="UnitPrice"/>
</xsl:attribute>

B.
<xsl:element name="UnitPrice">
<xsl:value-of select="UnitPrice"/>
</xsl:element>

C.
<xsl:attribute name="UnitPrice">
<xsl:value-of select="@UnitPrice"/>
</xsl:attribute>

D.
<xsl:element name="UnitPrice">
<xsl:value-of select="@UnitPrice"/>
</xsl:element>

  • ( + )Solution
Question

Assume that the XSLT stylesheet is applied to XML Document A, resulting in the output of XML Document B. Select the section of the XSLT stylesheet that correctly fits into (1) below.

[XML Document A]
<?xml version="1.0" ?>
<item>
    <itemName>XML Ballpoint Pen</itemName>
    <itemNo>PN001</itemNo>
    <size unit="cm">15</size>
</item>

[XSLT Stylesheet]
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <xsl:apply-templates select="item"/>
  </xsl:template>
  <xsl:template match="item">

[    (1)    ]

  </xsl:template>
</xsl:stylesheet>

[XML Document B]
<?xml version="1.0" ?>
<size unit="cm">15</size>

  1. <xsl:copy-of select="size"/>
  2. <xsl:copy select="size"/>
  3. <xsl:copy-of match="size"/>
  4. <xsl:element name="size"/>
  • ( + )Solution
Question

Select which of the following correctly describes the output results of an XSLT transformation of the "XML Document" using the "XSLT Style Sheet" below. Select any 1 option.

Note that the XSLT processor can output transformation results as a document. Line feeds and indents are not reflected.

[XML Document]
<?xml version="1.0"?>
<original xmlns="http://www.xmlmaster.org/">
  <data time="30">12345</data>
</original>

[XSLT Style Sheet]
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ns1="http://www.xmlmaster.org/">
  <xsl:template match="/">
    <value><xsl:apply-templates select="ns1:original/ns1:data"/></value>
  </xsl:template>
  <xsl:template match="ns1:data">
    <xsl:attribute name="time"><xsl:value-of select="@ns1:time"/></xsl:attribute>
    <xsl:value-of select="."/>
  </xsl:template>
</xsl:stylesheet>

1. <value/>

2 <value>12345</value>

3. <value time="">12345</value>

4 <value time="30">12345</value>

  • ( + )Solution