XSLT test questions from uni

Question 1:

Explain:

  1. Start from root: xml node
  2. match with node a
    • write <b>
    • down to node c
    • write <u>
    • get value called Hello
    • add end tag </u>
    • add end tag </b>
    • Done
  3. math with node d
    • write <i>
    • down to /xml/a
    • match with a
    • write <b>
    • match with c
    • write <u>
    • get value called Hello
    • add end tag </u>
    • add end tag </b>
    • add end tag </i>
    • Done
  4. Done

After two loops, the output will be:

<b><u>Hello</u></b> <i><<b><u>Hello</u></b>/i>

HelloHello


Question 2:

Explain:

  1. Start from Root: root
  2. match with shop
    • write <div style=”border:2px;background-color:lightblue;margin-left:10px”>
    • write <h4>shop<h4>
    • /root/*/* will divide into 2 branchs: left and right
    • go down to the left branch start from root to person
    • match with person
    • write <div style=”border:2px;background-color:aquamarine;margin-left:10px”>
    • write <h4>Person</h4>
    • match with employee
    • write <div style=”border:2px;background-color:lightgreen;margin-left:10px”>
    • write<u>Alexis</u>
      (Task:  Sales)
      <br/>
    • go down to the right branch start from root to employee
    • match with employee
    • write <div style=”border:2px;background-color:lightgreen;margin-left:10px”>
    • write<u>Blake</u>
      (Task:  Control)
      <br/>
  3. left branch traverse is done, now start with right branch traverse
    • match with person
    • write <div style=”border:2px;background-color:aquamarine;margin-left:10px”>
    • write <h4>Person</h4>
    • match with employee
    • write <div style=”border:2px;background-color:lightgreen;margin-left:10px”>
    • write<u>Blake</u>
      (Task:  Control)
      <br/>
  4. Done:

Result:

<div style=”border: 2px none; background-color: lightblue; margin-left: 10px;”><h4>Shop</h4><div style=”border: 2px none; background-color: aquamarine; margin-left: 10px;”><h4>Person</h4>
<div style=”border: 2px none; background-color: lightgreen; margin-left: 10px;”><h4>Employee</h4><u>Alexis</u>
(Task: Sales)
<br></div>
</div><div style=”border: 2px none; background-color: lightgreen; margin-left: 10px;”><h4>Employee</h4><u>Blake</u>
(Task: Control)
<br></div></div>

<div style=”border: 2px none; background-color: aquamarine; margin-left: 10px;”><h4>Person</h4>
<div style=”border: 2px none; background-color: lightgreen; margin-left: 10px;”><h4>Employee</h4><u>Blake</u>
(Task: Control)
<br></div>
</div>

Advertisements

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s