我正在使用Microsoft Word文件中的XSL Transformation转换XML文件。
我创建了这张表:
您可以在两列中看到这是一个按字母顺序排列的索引。
第一列包含城市名称;
第二列包含.........(仅用于布局);
第三列包含数字。
您可以看到例如:
ACCIAROLI ....................(很多空格)| ............. | 2665.3 - 2666.5 < / p>
在这种情况下,我会:
阿恰罗利.............................................. ........ | ............. | 2665.3 - 2666.5
我会在第一列中显示虚线,直到第一列结尾,以便改进表格格式。
这是我的XSLT 1.0:
<div>
<table style="layout:fixed; font-size:9pt; border-style:none; border-collapse:collapse; vertical-align:top; width:100%; font-family:Univers Condensed;" border="none" cellspacing="0" cellpadding="0">
<xsl:for-each select="//ITA_LIGHT_NUMBER[count(. | key('k', following-sibling::VICINITY | following-sibling::ITA_LIGHT_NAME[not(../VICINITY)])[1]) = 1]">
<xsl:sort select="following-sibling::VICINITY | following-sibling::ITA_LIGHT_NAME[not(../preceding-sibling::VICINITY)]"/>
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="passo" select="15"/>
<xsl:variable name="posto" select="following-sibling::VICINITY"/>
<xsl:if test="position() < $passo">
<tr>
<td> // First Column
<span style="text-transform:uppercase;">
<xsl:choose>
<xsl:when test="not(following-sibling::VICINITY)">
<xsl:value-of select="following-sibling::ITA_LIGHT_NAME"/>
<xsl:text>....................</xsl:text> //I would that This dotted line arrive at the end of column
<br/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="following-sibling::VICINITY != preceding::VICINITY[1] or not(preceding::VICINITY[1])">
<xsl:value-of select="following-sibling::VICINITY"/>
<xsl:text>....................</xsl:text>
<br/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</span>
</td>
<td style="width:2.00cm;"> //Second column
<span>................................</span>
</td>
<td> //third column
<xsl:choose>
<xsl:when test="not(following-sibling::VICINITY)">
<xsl:value-of select="."/>
<br/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="following-sibling::VICINITY != preceding::VICINITY[1] or not(preceding::VICINITY[1])">
<xsl:value-of select="(//ITA_LIGHT_NUMBER[following-sibling::VICINITY = $posto])[1]"/>
<xsl:if test="(//ITA_LIGHT_NUMBER[following-sibling::VICINITY = $posto])[1] != (//ITA_LIGHT_NUMBER[following-sibling::VICINITY = $posto])[last()]">
<xsl:text> - </xsl:text>
<xsl:value-of select="(//ITA_LIGHT_NUMBER[following-sibling::VICINITY = $posto])[last()]"/>
</xsl:if>
<br/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</div>
现在我正在阅读Enter Css File和connect xslt to external css,我尝试:(关于第一栏)
<xsl:when test="not(following-sibling::VICINITY)">
<xsl:value-of select="following-sibling::ITA_LIGHT_NAME"/>
<ul class="leaders.css">
<link rel="stylesheet" type="text/css" href="leaders.css" />
<li><span><xsl:text>....................</xsl:text></span></li>
</ul>
<br/>
</xsl:when>
此外,我创建了这个css文件leader.css,它包含:
ul.leaders li { clear: both; }
ul.leaders li span:first-child {
float: left;
padding: 0 .4em 0 0;
margin: 0;
}
ul.leaders li span + span {
float: right;
padding: 0 0 0 .4em;
margin: 0;
}
ul.leaders li:after {
content: "";
display: block;
overflow: hidden;
height: 1em;
border-bottom: 1px dotted;
}
这是一个可能的解决方案吗?
答案 0 :(得分:2)
问题不是针对XSL而是针对CSS的问题。您可以在CSS中以多种方式执行此操作,请参阅: