Tôi có một số nội dung html bên trong XML của mình. Trước đây tôi chỉ có thể sử dụng <xsl:copy-of select="customFields/customField[@name='mainContent']/html"/>
để kéo nội dung vào đúng khu vực. Yêu cầu mới là chuyển đổi <tr>
đầu tiên bên trong mỗi bảng <tbody>
thành một bộ thead/tr/th
.Chuyển đổi hàng của bảng HTML đầu tiên thành hàng tiêu đề cho mỗi bảng bằng cách sử dụng XSLT
Tôi đang bối rối về cách chuyển đổi, trên thực tế thậm chí không bờ bắt đầu từ đâu:
...
<customField name="mainContent" type="Html">
<html>
<h1>Page Heading</h1>
<p>Gusto te minim tempor elit quam. Dolore vel accumsan parum option me. Demonstraverunt congue nisl soluta tincidunt seacula. Soluta saepius demonstraverunt praesent claritatem mutationem. Modo te ullamcorper vel augue veniam. Nunc investigationes dolor iriure typi in.</p>
<p>Gusto te minim tempor elit quam. Dolore vel accumsan parum option me. Demonstraverunt congue nisl soluta tincidunt seacula. Soluta saepius demonstraverunt praesent claritatem mutationem. Modo te ullamcorper vel augue veniam. Nunc investigationes dolor iriure typi in.</p>
<table cellspacing="0" cellpadding="0" summary="" border="0">
<tbody>
<tr>
<td>Heading 1</td>
<td>Heading 2</td>
<td>Heading 3</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
</tbody>
</table>
</html>
</customField>
...
thành:
...
<customField name="mainContent" type="Html">
<html>
<h1>Page Heading</h1>
<p>Gusto te minim tempor elit quam. Dolore vel accumsan parum option me. Demonstraverunt congue nisl soluta tincidunt seacula. Soluta saepius demonstraverunt praesent claritatem mutationem. Modo te ullamcorper vel augue veniam. Nunc investigationes dolor iriure typi in.</p>
<p>Gusto te minim tempor elit quam. Dolore vel accumsan parum option me. Demonstraverunt congue nisl soluta tincidunt seacula. Soluta saepius demonstraverunt praesent claritatem mutationem. Modo te ullamcorper vel augue veniam. Nunc investigationes dolor iriure typi in.</p>
<table cellspacing="0" cellpadding="0" summary="" border="0">
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
<tr>
<td>sample</td>
<td>sample</td>
<td>sample</td>
</tr>
</tbody>
</table>
</html>
</customField>
...
Tốt câu hỏi, 1. Xem câu trả lời của tôi cho một giải pháp hoàn chỉnh và ngắn gọn, bằng cách sử dụng mẫu thiết kế XSLT cơ bản và mạnh mẽ nhất - quy tắc nhận dạng quá mức. –