Closed alexvanwoert closed 3 years ago
@alexvanwoert Sorry I didn't see this until now! I addressed this with you over Canvas, but it will help to take a look at the template rule in which you've set your <xsl:value-of select="...">
statement. It's important to note the context node for your <xsl:template match="...">
.
To get your rule to output anything, you'd need to add one more forward slash to the beginning to start at the document node and go down the tree like so: <xsl:value-of select="string-join(//root/title/chapter/p/location, ', ')"/>
. However, if you did so, you would output ALL the locations in ALL the chapters at once, and you almost certainly don't want to do that. You just want the locations within each specific chapter. So that is why you want to define this from the context of your template match node. If that is set up as I expect it is, it'll look like this:
<xsl:template match="chapter">
<tr>
<td>....</td>
<td><xsl:value-of select="string-join(descendant::location, ', ')"/></td>
<td>....</td>
</tr>
</xsl:template>
You could also write that as:
<xsl:template match="chapter">
<tr>
<td>....</td>
<td><xsl:value-of select="string-join(.//location, ', ')"/></td>
<td>....</td>
</tr>
</xsl:template>
But be careful to apply the dot .
because you need to prevent it from starting at the document node and spitting out ALL the locations in the whole novel! Using descendant::
or .//
means, "go down the tree from the starting point of the context node which is the chapter."
@alexvanwoert Also, when you see output, you'll also see lots of duplicates. So...you may wish to return distinct-values()
before you do the string-join()
.
To output a string-joined list of locations in my table for each chapter I tried