试图将我的 xml 中的 UNICODE_STRING 更改为仅在我的表中输出“STRING”而不是 Unicode。我创建了一个表,我在其中检索“类型”,但想更改名称并将其简化为仅字符串。
有没有办法创建一个变量并将其更改为我想要的?
我的 XSLT 代码是:
[
table = soup.find_all('table')[xy - here a number]
而且效果很好。只是在寻找一种方法来从我的 XML 中更改 UNICODE_STRING 的名称。
答案 0 :(得分:0)
我猜你想替换:
<xsl:value-of select="TYPE"/>
与:
<xsl:choose>
<xsl:when test="TYPE='UNICODE_STRING'">STRING</xsl:when>
<xsl:otherwise>
<xsl:value-of select="TYPE"/>
</xsl:otherwise>
</xsl:choose>
如果您的处理器支持 XSLT 2.0 或更高版本,您可以将其缩短为:
<xsl:value-of select="if (TYPE='UNICODE_STRING') then 'STRING' else TYPE"/>
答案 1 :(得分:0)
感谢迈克尔的建议!我并没有真正完美地解释,但我能够找到解决我的问题的方法。我使用了以下内容:
<script>function rep(){document.body.innerHTML =document.body.innerHTML.replace("UNICODE_STRING", "STRING");document.body.innerHTML =document.body.innerHTML.replace("ENUMERATION_VALUE", "NAMED SET");} </script>
<!-- this is where the script is called, notice its all done after the table is populated -->
<script>rep(); </script>
使用替换功能,我能够更改表格的输出。