在 XSL 的另一部分使用输出转义元素

问题描述 投票:0回答:1

我不知道如何保存包含 XML 表的输出转义元素并对该 XML 表进行转换。我似乎无法访问转义元素的节点。

这是 XML:

<TABEL_HUIDIGE_SITUATIE>&lt;ELEMNEW_TABEL Type=&quot;4912&quot;&gt;&lt;Table&gt;&lt;TableRow RowId=&quot;0&quot;&gt;&lt;TC Bold=&quot;true&quot;&gt;Nr.&lt;/TC&gt;&lt;TC Bold=&quot;true&quot;&gt;Omschrijving&lt;/TC&gt;&lt;TC Bold=&quot;true&quot;&gt;Bedrag&lt;/TC&gt;&lt;TC Bold=&quot;true&quot;&gt;BTW-productboekingsgroep&lt;/TC&gt;&lt;TC Bold=&quot;true&quot;&gt;Bedrag Incl BTW&lt;/TC&gt;&lt;/TableRow&gt;&lt;TableRow RowId=&quot;1&quot;&gt;&lt;TC Type=&quot;31488&quot;&gt;010&lt;/TC&gt;&lt;TC Type=&quot;31488&quot;&gt;Antenne BTW&lt;/TC&gt;&lt;TC Type=&quot;12799&quot;&gt;12.021,55&lt;/TC&gt;&lt;TC Type=&quot;31489&quot;&gt;21% INT&lt;/TC&gt;&lt;TC Type=&quot;31488&quot;&gt;14.546,08&lt;/TC&gt;&lt;/TableRow&gt;&lt;/Table&gt;&lt;/ELEMNEW_TABEL&gt;
</TABEL_HUIDIGE_SITUATIE>

未转义的 XML 将如下所示:

<?xml version="1.0" encoding="UTF-8"?><ELEMNEW_TABEL Type="4912"><Table><TableRow RowId="0"><TC Bold="true">Nr.</TC><TC Bold="true">Omschrijving</TC><TC Bold="true">Bedrag</TC><TC Bold="true">BTW-productboekingsgroep</TC><TC Bold="true">Bedrag Incl BTW</TC></TableRow><TableRow RowId="1"><TC Type="31488">010</TC><TC Type="31488">Antenne BTW</TC><TC Type="12799">12.021,55</TC><TC Type="31489">21% INT</TC><TC Type="31488">14.546,08</TC></TableRow></Table></ELEMNEW_TABEL>

这是 XSL:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl">

<xsl:template name="box2">
  <xsl:param name="rtf"/>
    <xsl:apply-templates select="exsl:node-set($rtf)/node()" mode="doe"/>
</xsl:template>

<xsl:template match="text()" mode="doe">
    <xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>

<xsl:template match="*" mode="doe">
    <xsl:copy-of select="."/>
</xsl:template>

<xsl:template match="/">
    <xsl:call-template name="box2">
      <xsl:with-param name="rtf">
 <xsl:value-of select="." />
      </xsl:with-param>
    </xsl:call-template>
</xsl:template>
</xsl:transform>

我不知道输出的转义内容是否被识别为XML或字符串。我无法在 内使用 xpath。我已经阅读了大约 50 个 stackoverflow 主题,但我似乎无法让它发挥作用。如何保存输出转义的 xml,以便可以转换 TC 节点?有人有建议吗?谢谢!

尝试了不同的方法来访问节点但没有结果。

xslt
1个回答
0
投票

使用 XSLT 3.0,您可以使用

parse-xml()
函数,该函数将返回已解析的 XML,您可以在 XSLT 中使用 XPath。

© www.soinside.com 2019 - 2024. All rights reserved.