gpt4 book ai didi

xml - XSLT 和 XSLFO 命名空间

转载 作者:行者123 更新时间:2023-12-04 17:00:49 25 4
gpt4 key购买 nike

我对 XSL 命名空间有以下问题。我使用带有一个 XSL 文件和一个 XML 文件的 FOP 生成 PDF。

这是我的 XML 文件:

<?xml version= "1.0" encoding= "ISO-8859-2"?>
<ReportContent>BLABLA<yt:picture src="pic.png"/></ReportContent>

这是我的 XSL 文件:
<?xml version="1.0" encoding="ISO-8859-2"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:yt="http://www.yt.com/text/2"
>
<xsl:template match="/">
<fo:root >
[...]
<fo:flow >
<fo:block> <xsl:apply-templates select='ReportContent'> </xsl:apply-templates></fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>



我需要包含命名空间 yt:。当我在 xml 中这样做时:
 <?xml version= "1.0" encoding= "ISO-8859-2"?>
<ReportContent xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:yt="http://www.yt.com/text/2">
BLABLA<yt:picture src="pic.png"/>
</ReportContent>

它完美地工作。

但在现实生活中,我无法向我的 xml 添加命名空间(创建 xml 的方式不允许这样做)。

所以我试图只在 xsl 上写它,但它根本不起作用。(我试图将它添加到 xsl 中的每个标签,但它不起作用)。

我不明白整个命名空间是如何工作的......

你能帮我找到在 xsl 中放置命名空间的位置,这样我就不会收到任何错误。

希望我的问题很清楚

提前致谢。

最佳答案

@Ricky,是的,必须更改 XML。对不起。它应该是这样的:

<?xml version= "1.0" encoding= "ISO-8859-2"?>
<ReportContent xmlns:yt="http://www.yt.com/text/2">BLABLA<yt:picture src="pic.png"/>
</ReportContent>

关于xml - XSLT 和 XSLFO 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6255152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com