像 xslt 这样的东西用于呈现纯文本 EDI 消息?
我经常遇到各种纯文本格式的 EDI 消息,例如
HEAD[customer,8][date,8][reference,10]
[lineno, 3][product, 8][quantity, 3][currency, 3][price, 10]...
以下格式: ..导致消息如下:
HEAD1122334420091031 LINDAHL
00100004711010USD0000234055
00200004712005USD0000004543
...
阅读上面的转储显然需要焦点,并且我经常发现自己失去了对列和字段的跟踪。如果有一种表达消息语法并获取标记文件(例如 HTML)的方法,那就太好了。
当然可以使用任何语言的定制脚本来完成此操作,但我很好奇:是否有一个用于转换纯文本的通用方法,就像 XSLT 对 XML 所做的那样?
I often encounter EDI messages in various plain text formats, for example the format:
HEAD[customer,8][date,8][reference,10]
[lineno, 3][product, 8][quantity, 3][currency, 3][price, 10]...
..resulting in messages like this:
HEAD1122334420091031 LINDAHL
00100004711010USD0000234055
00200004712005USD0000004543
...
Reading the above dump obviously requires focus, and I often find myself losing track of columns and fields. It would be nice to have a way of expressing the grammar of the message and getting a marked-up file (for example in HTML).
It is of course possible to do this with custom-made scripts in any language, but I'm curious: Is there a generic thing for transforming plain text, something like what XSLT does with XML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来像是 awk 的工作。它的设计正是为了解析这样的文本文件。它是基于规则的,与 XSLT 完全相同。它已经安装在您的 Unix 机器上 - 只需
man awk
即可。Looks like a job for
awk
. It was designed exactly to parse text files like that. It's rule-based, exactly like XSLT. It's already installed on your Unix box - justman awk
.