我有一个 XSL 文件,其中有一个 for-each 循环,并且我正在使用 EXSLT 处理器来提供一些附加功能(即字符串填充)。
我想要做的是填充所有字段,以便它们是该字段的最长记录的长度。例如,将每个名称与最长的名称一样长,然后将每个记录编号填充与最长的记录编号一样长。
希望我已经解释清楚了。
提前致谢。
I have an XSL file which has a for-each loop in it and I am using an EXSLT processor to give some added functionality (namely the string padding).
what I want to be able to do is pad out all fields so they are the length of the longest record for that field. For example, for each name to be as long as the longest name, and then for each record number to be padded as long as the longest record number.
Hope I have explained this okay.
Thanks in advance.
发布评论
评论(3)
只是为了好玩,这个样式表:
使用此输入:
输出:
Just for fun, this stylesheet:
With this input:
Output:
使用 C#,您可以迁移到 XSLT 2.0 处理器,如 Saxon 9 或 XQSharp,然后您可以轻松找到项目的最大长度并使用类似 http://www.xsltfunctions.com/xsl/functx_pad-string-to-length.html 来填充它们。
如果您想使用 XSLT 1.0 和 EXSLT 来完成此操作,请使用 http://www. exslt.org/math/functions/max/index.html 查找最大值并使用 http://www.dpawson.co.uk/xsl/sect2/padding.html 进行填充。
With C# you could move to an XSLT 2.0 processor like Saxon 9 or XQSharp and then you can easily find the maximum length of your items and use a function like http://www.xsltfunctions.com/xsl/functx_pad-string-to-length.html to pad them.
If you want to do it with XSLT 1.0 and EXSLT then use http://www.exslt.org/math/functions/max/index.html to find the maximum and use a solution in http://www.dpawson.co.uk/xsl/sect2/padding.html to pad.