Closed ajw120 closed 4 years ago
Update!
I have this now and I'm lost where to go now.
<xsl:template match="/">
<html>
<head>Skyrim</head>
<body>
<h2>Cast</h2>
<tr>
<th>Character</th>
<th>Loyalty</th>
<th>ALignment</th>
</tr>
<tr>
<xsl:apply-templates/>
<td><xsl:value-of select="cast/character/@id"/></td>
<td><xsl:value-of select="cast/character/@loyalty"/></td>
<td><xsl:value-of select="cast/character/@alignment"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
@ajw120 A couple of issues here:
1) You're missing a start tag for <table>
You'd want that between <h2>
and your first table row <tr>
. So that's probably making a problem for the output.
2) You're right to use <xsl:apply-templates/>
after you set up the table and its header row, but you want an @select
attribute to choose the part of the source document you want to reach into to retrieve each table row.
3) And you want a new <xsl:template>
with an @match="something"
to match on the element that holds the cast information for each character. Inside that new template rule you want to set up a table row (<tr>
) with the table data (<td>
) elements inside. You're setting those up too soon in the template that matches on your root document node--so you're probably getting a sort of data dump of ALL the @id
, @loyalty
, and @alignment
attributes in each <td>
right now. You need a separate template rule to process each cast member one by one--it won't work in the big template that matches on the document node!
@ajw120 Once you set up your new template rule, be careful to adjust your XPath. Remember, the XPath is a literal path down from the context of your @match
value.
Hello,
I am here looking for help, although I'm not entirely sure what to ask. I have the beginning starter layout, but I am lost on what I am exactly looking for or what I need to be inserting. This is such a broad question I know, but I am genuinely just stuck. I have
I just don't know exactly what I need to be adding I suppose is my question.