XSLT:有没有办法“继承”罐装功能?
我再次不得不拼凑一些 XSLT 以便将生成的 XML 转换为(而不是简单地生成 HTML)。
这次我又产生了巨大的似曾相识的感觉。我再次必须解决基本问题,例如:
- 如何将字符转换为有效的 html 实体引用
- 如何在转换为 html 时保留空格/回车符
- 如何转换为 HTML 而不是 xhtml
- 如何从 xml 格式 转换为可呈现的格式
- 如何用子字符串拆分字符串
这都是我之前多次解决过的问题。但每次我回到 XSLT 时,我都必须从头开始,每次都重新发明轮子。
如果它是一种编程语言,我将拥有一个可以调用的预设函数和过程的库。我会有子程序来执行经常重复的任务。我将从一个已经实现了丑陋的样板内容的基类继承。
XSLT 中是否有任何方法可以通过预装代码来发展、扩展和改进生态系统?
i am once again having to cobble together a bit of XSLT into order to turn generated XML into (rather than simply generating HTML).
i'm having huge deja-vu this time again. i'm once again having to solve again basic problems, e.g.:
- how to convert characters into valid html entity references
- how to preserve whitespace/carriage returns when converting to html
- how to convert to HTML as opposed to xhtml
- how to convert dates from xml format into presentable format
- how to tear apart strings with substring
This is all stuff that i've solved many times before. But every time i come back to XSLT i have to start from scratch, re-inventing the wheel every time.
If it were a programming language i would have a library of canned functions and procedures i can call. i would have subroutines to perform the commonly repeated tasks. i would inherit from a base class that already implements the ugly boilerplate stuff.
Is there any way in XSLT to grow, expand and improve the ecosystem with canned code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然这不是必需的。
是的,XSLT 是一种编程语言。
是的,您可以在 XSLT 中执行此操作。
是的,XSLT 中有一些非常相似的东西。
即使在 XSLT 1.0 中,也有支持可重用性的强大标准功能:
< /a>XSLT 2.0 添加了一些更强大的功能:
的参数
有多个 XSLT 库已经存在相当长一段时间了:
XPath 2.1 和 XSLT 2.1 添加高阶函数作为标准。函数成为一流的数据类型。
This isn't necessary, of course.
Yes, XSLT is a programming language.
Yes, you can do this in XSLT.
Yes, there is something quite similar in XSLT.
Even in XSLT 1.0 there are powerful, standard features that support reusability:
<xsl:import>
<xsl:include>
<xsl:apply-templates>
<xsl:call-template>
<xsl:apply-imports>
XSLT 2.0 adds a few even more powerful features:
<xsl:function>
<xsl:apply-imports>
<xsl:next-match>
There have been several XSLT libraries for quite some time:
XPath 2.1 and XSLT 2.1 add Higher-Order Functions as standard. Functions become first-class datatypes.