linux - xslt 表固定列

标签 linux xslt

这是我的 xslt 表代码。我想为名称、尺寸日期设置固定的列。我想在代码中控制这些列的宽度,而不需要根据数据设置列大小。谢谢。


  <h1><table border="0">
     <tr bgcolor="#1E90ff">
         <th>Name</th>
         <th>Size</th>
         <th>Date</th>
     </tr>
     <xsl:for-each select="list/*">
     <xsl:sort select="@mtime"/>

         <xsl:variable name="name">
             <xsl:value-of select="."/>
         </xsl:variable>
         <xsl:variable name="size">
             <xsl:if test="string-length(@size) &gt; 0">
                 <xsl:if test="number(@size) &gt; 0">
                     <xsl:choose>
                             <xsl:when test="round(@size div 1024) &lt; 1"><xsl:value-of select="@size" /></xsl:when>
                             <xsl:when test="round(@size div 1048576) &lt; 1"><xsl:value-of select="format-number((@size div 1024), '0.0')" />K</xsl:when>
                             <xsl:otherwise><xsl:value-of select="format-number((@size div 1048576), '0.00')" />M</xsl:otherwise>
                     </xsl:choose>
                 </xsl:if>
             </xsl:if>
         </xsl:variable>
         <xsl:variable name="date">
             <xsl:value-of select="substring(@mtime,9,2)"/>-<xsl:value-of select="substring(@mtime,6,2)"/>-<xsl:value-of select="substring(@mtime,1,4)"/><xsl:text> </xsl:text>
             <xsl:value-of select="substring(@mtime,12,2)"/>:<xsl:value-of select="substring(@mtime,15,2)"/>:<xsl:value-of select="substring(@mtime,18,2)"/>
         </xsl:variable>

     <tr>
         <td valign='top'><img src='/.icons/unknown.gif' alt='[   ]' width='16' height='16' /><a href="{$name}"><xsl:value-of select="."/></a></td>
         <td align="left"><xsl:value-of select="$size"/></td>
         <td><xsl:value-of select="$date"/></td>
     </tr>

     </xsl:for-each>
  </table></h1>

最佳答案

这就是我要找的

<tr>
 <th width="70%">Name</th>
 <th width="19%">Size</th>
 <th width="11%">Date</th>
</tr>

关于linux - xslt 表固定列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58345321/

相关文章:

python - 在 Python 中记录和旋转 stdout 和 stderr

xml - 选择一个带有 xmlns 的节点?

java - 请求澄清多线程环境中 TransformerFactory 的 XSLT Transformer

xslt - XPath轴与XSLT/Xpath中的位置路径表达式相比,性能更好

json - 使用 XSLT 编写 JSON

xml - Xslt 组父/子

linux - tty_flip_buffer_push() 将数据发回给自己

linux - 在 Linux 中修改共享库

python - 如何连接多个文本或 xml 文件但省略每个文件中的特定行?

php - 如何从 PHP 使用 bash 脚本?