如何处理“<"和“>"在 xslt 中的正则表达式 [英] how to handle "<" and ">" in regex in xslt
问题描述
我有 XML 格式的字符串,<italic>a</italic>
并且我正在使用 xsl:analyze-string
使用此模式提取所有斜体字:"
.我知道我可以在斜体上使用模板匹配,但这里的要求是使用正则表达式匹配它.我正在尝试编写这样的表达式,(
,但 XSLT 处理器在开头的 <
标签.
I have string in XML, <italic>a</italic>
and I am using xsl:analyze-string
to extract all italic words with this pattern: "<italic>a</italic>"
. I know I can use template match on italic but the requirement here is to match it using regex. I am trying to write the expression like this, (<italic>)[a-z]+</italic>
, but the XSLT processor is throwing an error on the opening <
tag.
知道如何处理正则表达式中的开始和结束标记吗?
Any idea how to handle opening and closing tags in regex?
推荐答案
<italic>a</italic>
是一个普通的 xml 元素,如果你使用的是 saxon xslt 处理器然后使用扩展函数 net.sf.saxon.serialize 序列化 xml,然后应用正则表达式.效果很好.
<italic>a</italic>
is an ordinary xml element, if you are using saxon xslt processor then use an extensions function net.sf.saxon.serialize to serialize the xml and then apply regular expression. It works great.
这篇关于如何处理“<"和“>"在 xslt 中的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!