使用XSLT格式化表中的虚线 [英] Formatting dotted line inside a table using XSLT

查看:274
本文介绍了使用XSLT格式化表中的虚线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Microsoft Word文件中使用XSL转换转换XML文件。

我创建了此表:

>

您可以看到这是一个按字母顺序排列的两列索引。

You can see that this is an index alphabetical in two column.

第一列包含城市名称;

The first column contains the city name;

第二列包含.........(仅用于布局);

The second column contains ......... (serves only for layout);

第三列包含数字。

您可以看到例如:

ACCIAROLI .......... ..........(很多空格)| ............. | 2665.3 - 2666.5

ACCIAROLI.................... (a lot of blank space)|.............|2665.3 - 2666.5

在这种情况下,我会:

ACCIAROLI ............................ .......................... | ............. | 2665.3 - 2666.5

ACCIAROLI......................................................|.............|2665.3 - 2666.5

我会在第一列中的虚线,直到第一列的结尾,以改善表格格式。

这是我的XSLT 1.0:

This is my 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() &lt; $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>

现在我正在阅读输入Css文件将xslt连接到外部css ,然后尝试:(关于第一列)

Now I am reading from Enter Css File , and connect xslt to external css and I try to: (About First Column)

<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,它包含:

Furthermore, i create this css file leader.css, it contains:

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;
}

这是可能的解决方案吗? >

推荐答案

问题是不是XSL而是CSS的问题。您可以在CSS中以多种方式实现此功能,请参阅:

The question is a question not for XSL but for CSS. You can do that in many ways in CSS, see this:

http://www.w3.org/Style/Examples/007/leaders.en.html

这篇关于使用XSLT格式化表中的虚线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆