Question

Please create homework2.xsl and try to use xqeury expression to get following query result. (tips: the...

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"

Homework Answers

Answer #1

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:


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT