如何获得一个子弹点黑色圆圈而不是使用XSLT的HTML代码

问题描述 投票:-1回答:2

我有一个简单的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="&#149;">
<xsl:copy>
  <xsl:apply-templates select="•" />
  <xsl:apply-templates />
 </xsl:copy>
</xsl:template>
</xsl:transform>
xml xslt xsl-fo ecrion
2个回答
1
投票

如果没有看到您的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(., '&#149;', '&#8226;')" />
</xsl:template>

</xsl:stylesheet>

这将用BULLET字符(•)替换所有出现的MESSAGE WAITING控制字符(??)。


0
投票

您的来源采用“Windows-1252”编码(或类似的Windows“代码页”)。参见,例如,它所指的https://superuser.com/questions/1164809/whats-is-the-different-beween-western-european-windows-1252-and-ansi-encoding#1164814https://en.wikipedia.org/wiki/Windows-1252

如果您可以执行以下任一操作,则不需要text()模板和translate()

  • 以UTF-8(或UTF-16)而不是Windows-1252生成XML
  • 在文档开头生成或修改XML声明,以便将编码标识为Windows-1252(并使用了解Windows-1252的XML处理器)
  • 使用诸如xsltproc之类的XSLT处理器,它允许您指定输入文档的编码
  • 使用iconvhttps://en.wikipedia.org/wiki/Iconv)或类似方法将Windows-1252 XML转换为UTF-8(如果确​​实如此,则转换后,删除或修改XML声明,实际上将编码标识为Windows-1252)
© www.soinside.com 2019 - 2024. All rights reserved.