切换到XSLT文件中的参数doctype system
这是我第一次使用XSLT:切换到XSLT文件中的参数doctype system,xslt,Xslt,这是我第一次使用XSLT: 我需要传递doctype系统参数: 您能验证我的XSLT是否正确吗 <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="w3.org/1999/XSL/Transform"> <xsl:output method='xml' indent='no' version='1.0' encoding='utf-8' doctype-public='xxx' doct
我需要传递
doctype系统
参数:
您能验证我的XSLT是否正确吗
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="w3.org/1999/XSL/Transform">
<xsl:output method='xml' indent='no' version='1.0' encoding='utf-8' doctype-public='xxx' doctype-system="{$pURL}" />
<xsl:strip-space elements=""/>
<xsl:param name="pURL" select="'127.0.0.1:8080/dtd/?param'"/>
;
<xsl:template match="/">
<xsl:variable name="param"></xsl:variable> <xsl:apply-templates />
</xsl:template>
<xsl:template match="@ | ">
<xsl:copy>
<xsl:apply-templates select="@ | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
;
如果您确实想要参数化xsl:output
元素的此类属性,那么您需要使用XSLT 3.0处理器,如Saxon 9 PE或EE或Exselt或Altova 2017,在那里您可以使用xsl:param
和a,如下所示:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:param name="doctype-uri" static="yes" as="xs:string" select="'http://example.com/foo.dtd'"/>
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-public="foo" _doctype-system="{$doctype-uri}"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
对于早期版本的XSLT,您需要编写两个样式表,其中第一个样式表采用普通参数,并生成具有所需属性的第二个样式表
一般来说,如果您的目标是将DTD请求重定向到本地副本,那么您应该查看XML目录,而不是对每个文档的DOCTYPE进行更改。欢迎这样做。请看一看。您可能还需要检查、和以及如何创建。张贴您尝试过的代码和收到的错误。尽可能具体,因为这将导致更好的答案。请更新您的问题以添加信息。让我们更容易理解和回答您的问题!我从您的评论中合并了您的XML/XSLT代码,并通过修复一些标记使其格式良好。