如何对这些 XSLT 文档进行 DRY 编辑
我已经做了两页,现在我想知道是否可以干燥它们。
这里是 XSLT:
首页:http://pastebin.com/yuZL913W dagboek-page: http://pastebin.com/6FGYvpvf (已编辑)
Roelof
抱歉,其中一个链接是错误的。 我编辑了这个。
我的问题是如何干燥这些零件,以便我可以重复使用零件。只有
不同。 我想我理解填空,但它是一个很大的 xslt 文件。如果没有命名模板和调用模板,这可能吗?I have made two pages and now I wonder if I can DRY them.
Here the XSLT:
Frontpage: http://pastebin.com/yuZL913W
dagboek-page: http://pastebin.com/6FGYvpvf (Edited)
Roelof
Sorry one of the links is wrong.
I edited this.
My question is how to DRY these so I can reuse parts. Only the <div id="posts">
is different.
I think I understand the fill in the blanks but it is one big xslt file. Is this possible without named templates and call-templates
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法 - 我称之为“填空”将内容与处理分开并参数化处理:
< strong>渲染文件 (c:/temp/delete/nc3.xml):
数据文件 (c:/temp/delete/data.xml):
XSLT 代码:< /strong>
源 XML 文件(不是使用):
当对任何 XML 文件(未使用)执行上述转换时,渲染文件将使用数据文件中的数据填充。处理占位符
gen:data
元素的模板是虚拟的,但仍然演示了此处理的工作原理。处理结果:
请注意:
此代码可以使用任何数据文档中的数据(再次强调)填充任何渲染文档(作为外部参数传递的路径)作为外部参数传递的路径)。因此,可以创建填充不同数据的不同输出/格式。
要替换为“实时内容”的占位符(
gen:data
元素)可以具有不同的格式和语义 - 想象力不受限制。编辑者(非 XSLT 专家)可以独立于 XSLT 开发人员处理一个或多个呈现文档。
实现了更高程度的可重用性、灵活性和可维护性。
Here is one way -- what I call "Fill-in-the-blanks" to separate content from processing and to parameterize processing:
Rendering file (c:/temp/delete/nc3.xml):
Data file (c:/temp/delete/data.xml):
XSLT code:
Source XML file (not used):
When the above transformation is performed on any XML file (not used), the rendering file is populated with data from the data file. The templates that process the placeholder
gen:data
elements, are dummy but still demonstrate how this processing works.The result of the processing:
Do note:
This code can populate any rendering document (path passed as an external parameter) using the data from any data document (again path passed as an external parameter). Thus it becomes possible to create different outputs/formats populated with different data.
The placeholders (
gen:data
elements) to be replaced with "live content" can have different format and semantics -- no limits to one's imagination.Editors (non-XSLT experts) can work on one or more rendering documents independently from each other and from the XSLT developers.
A higher degree of reusability, flexibility and maintainability is achieved.