带 Padding 的 XSL 左右对齐
XSLT 1.0 中是否有可用的标准模板可以进行调整并将字段填充到最大长度?
Is there any standard template in XSLT 1.0 available which does justification and pad the field to max length?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,XSLT 没有附带填充功能,好处是,正如这篇博客文章所指出的那样,这样做非常简单:http://www.dpawson.co.uk/xsl/sect2/padding.html
(网络存档版本:http://web.archive.org/web/20171225234313/http://www.dpawson.co.uk/xsl/sect2/padding.html )
例如,如果您想右填充 a您可以执行 10 个空格字符串:
如果您需要左填充,您可以更改 concat 参数的顺序,如下所示:
请注意,带有空格的字符串应包含与填充相同数量的字符需要,所以如果你想要一个 10 的 pad,你将需要一个 10 个空格的字符串。
Unfortunately XSLT does not comes with the padding function, the good part is that is very simple to do so as pointed by this blog post: http://www.dpawson.co.uk/xsl/sect2/padding.html
(Web archive version: http://web.archive.org/web/20171225234313/http://www.dpawson.co.uk/xsl/sect2/padding.html )
For example if you want to right pad a 10 spaces string you can do:
if you need a left pad you can change the order of the concat parameters as following:
Notice that the string with spaces should contain the same amount of chars as your padding is needing, so if you want a 10 pad, you will need a 10 spaces string.