xslt 2.0如何替换$转义美元(转换为LaTeX) [英] xslt 2.0 how replace $ by escaped dollar (for conversion to LaTeX)
问题描述
我将XML转换为LaTeX。当然,LaTeX需要转义诸如$和#之类的字符。我在替换功能中尝试过以下操作,但它不起作用。 (他们在没有替换功能的情况下工作。)
< xsl:template match =xyz:doc>
\subsubsection {< xsl:value-of select =replace(xyz:headline,'(\ $)','\ $ 1')/>}
...
< / xsl:template>
< xsl:template match =xyz:doc>
\subsubsection {< xsl:value-of select =replace(xyz:headline,'\ $','\ $')/>}
...
< / xsl:template>
要转义的可能内容是:
本地定义的字段#931或
本地定义的子字段$ b
我做错了什么?
非常感谢您的答案!
如果您要替换一个美元符号 $输入中的
,然后使用 \ $
的输入中 replace(xyz:headline,'\ $' '\\\ $')
。
如果有几个字符需要相同的转义,那么替换(xyz:headline,'([$#])','\\ $ 1')
应该做。
http://xsltransform.net/bdxtqX/1
I am new to XSLT. I googled extensively but couldn't figure out how to do the following:
I am transforming XML to LaTeX. Of course, LaTeX needs to escape characters such as $ and #. I tried the following in the replace function but it does not work. (They do work without the replace function.)
<xsl:template match="xyz:doc">
\subsubsection{<xsl:value-of select="replace( xyz:headline, '(\$)', '\$1' )"/>}
...
</xsl:template>
<xsl:template match="xyz:doc">
\subsubsection{<xsl:value-of select="replace( xyz:headline, '\$', '\$' )"/>}
...
</xsl:template>
Possible content to be escaped is: "Locally defined field #931" or "Locally defined subfield $b"
What am I doing wrong? Many thanks for your answers!
If you want to replace a dollar symbol $
in the input with \$
in the output then use replace(xyz:headline, '\$', '\\\$')
.
If there are several characters that need the same escaping then replace(xyz:headline, '([$#])', '\\$1')
should do.
Sample at http://xsltransform.net/bdxtqX/1
这篇关于xslt 2.0如何替换$转义美元(转换为LaTeX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!