使用 xsl 插入 <?xml-stylesheet 标签 [英] insert <?xml-stylesheet tag with xsl

查看:26
本文介绍了使用 xsl 插入 <?xml-stylesheet 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 XSLT 添加样式表引用?

How can I add stylesheet reference with XSLT?

我试图通过第一个转换去除一些大的输入 XML,并且需要在客户端上应用第二个转换.因此,第一个转换必须输出正确的引用,例如:

I'm trying to strip down some large input XML with the first transform, and need the second transform to be applied on the client. Thus the first transform has to output the correct reference, e.g.:

<?xml-stylesheet type="text/xsl" href="client.xsl"?>

总结一下它是 XML->transform1(server)->XML->transform2(client)->HTML

To recap it's XML->transform1(server)->XML->transform2(client)->HTML

到目前为止,我可以让它工作的唯一方法是使用 xsl:text disable-output-escaping 和 CDATA:

The only way I can make it to work so far is by using xsl:text disable-output-escaping and CDATA:

<xsl:text disable-output-escaping="yes"><![CDATA[<?xml-stylesheet type="text/xsl" href="/efo/efo_class.xsl"?>]]>

肯定有更好的方法.

推荐答案

基于 XSLT 规范,创建处理指令:

Based on the XSLT spec, Creating Processing Instructions:

<xsl:processing-instruction name="xml-stylesheet">
  <xsl:text>type="text/xsl" href="client.xsl"</xsl:text>
</xsl:processing-instruction>

将创建处理指令:

<?xml-stylesheet type="text/xsl" href="client.xsl"?>

这篇关于使用 xsl 插入 &lt;?xml-stylesheet 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆