考虑以下简化示例:
XML
<PSQ2><p>Going beyond working hours to meet release timeline and other priority stuff.</p><p>Skill set wise, I feel he is technically very well sound. Behavior wise, he is very friendly, make people feel like he is one of a family member. He advices people in both personal and professional ways. So far I didn&#39;t feel that he keeps double thoughts.</p><p><span>He has shown good ability to analyze issues, make sound decisions and overcome problems. Always trying to improve code quality. </span></p></PSQ2>
XSLT 3.0
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="PSQ2">
<result>
<xsl:value-of select="parse-xml-fragment(.)/p" />
</result>
</xsl:template>
</xsl:stylesheet>
结果
<?xml version="1.0" encoding="UTF-8"?>
<result>Going beyond working hours to meet release timeline and other priority stuff. Skill set wise, I feel he is technically very well sound. Behavior wise, he is very friendly, make people feel like he is one of a family member. He advices people in both personal and professional ways. So far I didn't feel that he keeps double thoughts. He has shown good ability to analyze issues, make sound decisions and overcome problems. Always trying to improve code quality. </result>
parse-xml-fragment()
功能需要支持XSLT 3.0的处理器。如果没有这个,从转义标记中提取文本将变得更加困难。
将转义标记解析为 XML 后,您可以按照您喜欢的任何方式将其处理为 XML - 例如:
<xsl:template match="PSQ2">
<result>
<xsl:for-each select="parse-xml-fragment(.)/p">
<xsl:number format="1. "/>
<xsl:value-of select="." />
<xsl:text> </xsl:text>
</xsl:for-each>
</result>
</xsl:template>
会产生:
<result>1. Going beyond working hours to meet release timeline and other priority stuff.
2. Skill set wise, I feel he is technically very well sound. Behavior wise, he is very friendly, make people feel like he is one of a family member. He advices people in both personal and professional ways. So far I didn't feel that he keeps double thoughts.
3. He has shown good ability to analyze issues, make sound decisions and overcome problems. Always trying to improve code quality.
</result>