How do I select a specific attribute value from a series of values using XQuery?
My XML file looks like this:
<unit id="01" xref="entry01 entry02">
How do I select a specific value — such as entry01 — from the xref attribute and assign it to a variable?
I need to select the individual values from the attribute xref, because additional features for these values are defined later in the file:
<features xref="entry01" font-size="2">
<features xref="entry02" font-size="3">
I would like to organize the entries into a table such as one exemplified below. The columns defined by the attributes as follows: unit id, xref, font-size.
<tbody>
<tr>
<td>01</td>
<td>entry01</td>
<td>2</td>
</tr>
<tr>
<td>01</td>
<td>entry02</td>
<td>3</td>
</tr>
</tbody>
Use
fn:tokenizeto split at space (or all whitespace) characters, depending on you needs:Split at a single space:
Allow multiple spaces directly following each other:
Split at a single whitespace (I changed the attribute value to contain a tab character):