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
In XML Document B (the output result), the UnitPrice element is
described as the child element of the Orange element. Accordingly, the
correct notation for (1) is the notation that creates the UnitPrice
element. The xsl:element command is the function that creates elements.
The xsl:attribute command is the function that creates attributes.
To output element content, the xsl:value-of command is used, with the
XPath method showing the output value included in the select attribute.
Since the UnitPrice attribute is written in the source XML document,
the "@" symbol must be attached. Accordingly, the correct answer is D.