Xml 在xslt中转义未转义的值
我在xslt转换中遇到了问题,因为原始xml没有双引号这样的转义字符 我正在使用xsltproc进行测试,但我没有处理正确的结果。我寻找了很多解决方案,但似乎我找不到适合我的问题的正确解决方案。任何帮助都将不胜感激 源xml:Xml 在xslt中转义未转义的值,xml,xslt,escaping,Xml,Xslt,Escaping,我在xslt转换中遇到了问题,因为原始xml没有双引号这样的转义字符 我正在使用xsltproc进行测试,但我没有处理正确的结果。我寻找了很多解决方案,但似乎我找不到适合我的问题的正确解决方案。任何帮助都将不胜感激 源xml: <test>abc"abc"</test> xslt: 结果我得到: <?xml version="1.0"?> <test2 property="abc"abc"" /> 结果我需要:
<test>abc"abc"</test>
xslt:
结果我得到:
<?xml version="1.0"?>
<test2 property="abc"abc"" />
结果我需要:
<?xml version="1.0"?>
<test2 property="abc"abc"" />
详细输出:
xsltProcessOneNode: applying template '/' for /
xsltApplySequenceConstructor: copy text
<test2 property="
xsltCopyText: copy text
<test2 property="
xsltValueOf: select ./test
xsltCopyTextString: copy text abc"abc"
xsltValueOf: result 'abc"abc"'
xsltApplySequenceConstructor: copy text " />
xsltCopyText: copy text " />
freeing transformation dictionary
freeing dictionary from stylesheet
谢谢你的帮助
编辑
新发现:如果我添加&签名,它将正确转义到&但不是。根据我在互联网上读到的内容,我认为它也应该被转义。您问题中的预期输出完全正确吗?它不应该是test2 property=abcabc/?如果它应该是转义标记,那么它实际上需要是test2 property=abc&;引用;abc&;QUOTE;/用双引号转义了两次,所以它们在一轮转义后结束。
xsltProcessOneNode: applying template '/' for /
xsltApplySequenceConstructor: copy text
<test2 property="
xsltCopyText: copy text
<test2 property="
xsltValueOf: select ./test
xsltCopyTextString: copy text abc"abc"
xsltValueOf: result 'abc"abc"'
xsltApplySequenceConstructor: copy text " />
xsltCopyText: copy text " />
freeing transformation dictionary
freeing dictionary from stylesheet