【发布时间】:2011-05-18 14:12:13
【问题描述】:
我正在尝试从 xml 文件中的 cmets 生成格式良好的 html 文档。目前我有一个 xml 文件,用于生成 xml 表的 html 列表。为了让我添加有关表的 cmets,我手动将 cmets 添加到输出 html 文件中。
如果可能的话,我希望将 html 代码作为注释放在 xml 文件中,并让 xslt 使用该注释来创建格式正确的文档。
这里是 xml 文件中被注释的部分。这里有 html 换行语法,我希望 xslt 将其读取为 html。我认为必须有更好的方法来使用原始 xml 来创建它,但是,我不希望在 xml 文件中读取 cmets,所以不希望它作为表条目。
<table name="ers_benchmark_defn" xmlns="">
<!-- This table contains mapping between hierarchy nodes and their respective benchmarks. The columns should be populated as follows:<br>
<ul>
<li>HIERARCHY_NODE<br>
This column contains the name of the hierarchy node in the ERS Risk Hierarchy.</ul>
<ul>
<li>BENCHMARK<br>
The column can be populated with either;<br>
a Calypso portfolio name,<br>
an ERS Risk Hierarchy name, or<br>
an ERS Risk Hierarchy node name.<br><br>
In the latter case, the column should be populated with the hierarchy node name and the hierarchy to which it belongs, separated by a percentage symbol, %.</ul>
<ul>
<li>BENCHMARK_TYPE<br>
If the value in the benchmark column is an ERS hierarchy or hierarchy node name, this column should be populated with the value HIERARCHY. Otherwise, when using a Calypso portfolio name, it should not be populated.</ul>
<ul>
<li>SCALING_FACTOR<br>
This column should be populated with the scaling factor by which the benchmark results should be multiplied. To use MTM scaling, leave this column unpopulated.</ul>
See the ERS 10.2 Release notes for further information.<br><br> -->
<column name="hierarchy_node" nullable="false" type="string" scale="255"/>
<column name="benchmark" nullable="false" type="string" scale="255"/>
<column name="benchmark_type" nullable="true" type="string" scale="32"/>
<column name="scaling_factor" nullable="true" type="float"/>
这是我为使用注释而制作的 xsl 文件的一部分,但它不解释 html。
<tr class="info" width="100%">
<td colspan="4"><xsl:value-of select="comment()"/></td>
</tr>
手动格式化后所需的输出如下所示:
<p>
<table border="1" cellpadding="2" cellspacing="0">
<tr class="title">
<th colspan="4"><a name="ers_benchmark_defn"></a>ers_benchmark_defn
</th>
</tr>
<tr class="info" width=100%>
<th colspan=4 align=left>This table contains mapping between hierarchy nodes and their respective benchmarks. The columns should be populated as follows:<br>
<ul>
<li>HIERARCHY_NODE<br>
This column contains the name of the hierarchy node in the ERS Risk Hierarchy.</ul>
<ul>
<li>BENCHMARK<br>
The column can be populated with either;<br>
a Calypso portfolio name,<br>
an ERS Risk Hierarchy name, or<br>
an ERS Risk Hierarchy node name.<br><br>
In the latter case, the column should be populated with the hierarchy node name and the hierarchy to which it belongs, separated by a percentage symbol, %.</ul>
<ul>
<li>BENCHMARK_TYPE<br>
If the value in the benchmark column is an ERS hierarchy or hierarchy node name, this column should be populated with the value HIERARCHY. Otherwise, when using a Calypso portfolio name, it should not be populated.</ul>
<ul>
<li>SCALING_FACTOR<br>
This column should be populated with the scaling factor by which the benchmark results should be multiplied. To use MTM scaling, leave this column unpopulated.</ul>
See the ERS 10.2 Release notes for further information.<br><br></th>
</tr>
<tr class="header">
<th>column name</th>
<th>nullable</th>
<th>type</th>
这些是完整代码的摘录,但我认为这应该足够有人帮助我了。
谢谢!
【问题讨论】: