我有一个简单的xslt将xml转换为xsl-fo但是当生成我的xml时它会生成一个子弹点
•
当我使用我的转换转换为xsl-fo并将其传递给ecrion以呈现pdf时,它无法识别子弹点的html代码我想为我的XSLT添加一些条件以将其更改为完整的黑色圆圈项目符号任何建议请
<?xml version="1.0"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
<xsl:template match="/doc">
<Generic><xsl:apply-templates /></Generic>
</xsl:template>
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="•">
<xsl:copy>
<xsl:apply-templates select="•" />
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
</xsl:transform>
如果没有看到您的XML输入和预期输出,我们只能猜测。或许尝试:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/doc">
<Generic>
<xsl:apply-templates />
</Generic>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="translate(., '•', '•')" />
</xsl:template>
</xsl:stylesheet>
这将用BULLET字符(•)替换所有出现的MESSAGE WAITING控制字符(??)。
您的来源采用“Windows-1252”编码(或类似的Windows“代码页”)。参见,例如,它所指的https://superuser.com/questions/1164809/whats-is-the-different-beween-western-european-windows-1252-and-ansi-encoding#1164814和https://en.wikipedia.org/wiki/Windows-1252。
如果您可以执行以下任一操作,则不需要text()
模板和translate()
:
xsltproc
之类的XSLT处理器,它允许您指定输入文档的编码iconv
(https://en.wikipedia.org/wiki/Iconv)或类似方法将Windows-1252 XML转换为UTF-8(如果确实如此,则转换后,删除或修改XML声明,实际上将编码标识为Windows-1252)