Please create homework2.xsl and try to use xqeury expression to get following query result.
(tips: the attribute symbol starts-with “C”).
homework2.xml Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="homework2.xsl" ?>
<stocks>
<stock symbol="INTC">
<name>Intel Corporation</name>
</stock>
<stock symbol="CSCO">
<name>Cisco Corporation</name>
</stock>
<stock symbol="DELL">
<name>Dell Corporation</name>
</stock>
<stock symbol="MSFT">
<name>Microsof Corporation</name>
</stock>
<stock symbol="SUNW">
<name>Sun Corporation</name>
</stock>
<stock symbol="CMGI">
<name>Cmgi Corporation</name>
</stock>
</stocks>
Query Result:
stock Element attributes symbol="CSCO"
stock Element attributes symbol="CMGI"
Code:
for $x in /stocks/stock
where $x[name='Cmgi Corporation'] or $x[name='Cisco
Corporation']
return "stock Element attributes symbol="||$x/[@symbol]/data()
or
for $x in doc('homework2.xml')/stocks/stock
where $x[name='Cmgi Corporation'] or $x[name='Cisco
Corporation']
return "stock Element attributes symbol="||$x/[@symbol]/data()
Output:
Get Answers For Free
Most questions answered within 1 hours.