gpt4 book ai didi

java - 避免使用 xslt 命名空间

转载 作者:行者123 更新时间:2023-12-01 10:52:35 25 4
gpt4 key购买 nike

我试图避免(为了创建新的 HTML 文件)输入文件中的 namespace 。我的 xslt 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="import_lc_iss">
<xsl:template match="/">
<html>
<body>
<h2>Recieved Message </h2>
<table border="1">
<tr >
<th>Entity</th>
<th>Reference Number</th>
<th>Transaction Date</th>
</tr>
<tr>
<td><xsl:value-of select="/header/entity"/></td>
<td><xsl:value-of select="/header/reference_no"/></td>
<td><xsl:value-of select="/header/transaction_date"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

我的 xml 输入如下所示:

  <?xml version="1.0" encoding="UTF-8"?>
<import_lc_iss xmlns="interface.nicom.allnett">
<header direction="Outgoing" send_date="2015-09-10T19:25:24+03:00">
<entity>001</entity>
<customer id="11111111-1"/>
<deal_no/>
<identity deal_type="01" step="ISS" step_no="0"/>
<reference_no>LCI00000000042</reference_no>
<transaction_date>2015-09-10T19:25:14+03:00</transaction_date>
</header>
</import_lc_iss>

为了检索实体标签内的内容。我正在尝试跳过 name 空间。我尝试添加到样式表

排除结果前缀=“import_lc_iss”

但是没有成功。有什么想法如何获取这些值吗?

提前致谢

最佳答案

命名空间是要使用的,而不是避免的。而 exclude-result-prefixes 则不能以这种方式工作。尝试:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="interface.nicom.allnett"
exclude-result-prefixes="ns1">

<xsl:template match="/ns1:import_lc_iss">
<html>
<body>
<h2>Recieved Message </h2>
<table border="1">
<tr >
<th>Entity</th>
<th>Reference Number</th>
<th>Transaction Date</th>
</tr>
<tr>
<td><xsl:value-of select="ns1:header/ns1:entity"/></td>
<td><xsl:value-of select="ns1:header/ns1:reference_no"/></td>
<td><xsl:value-of select="ns1:header/ns1:transaction_date"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

关于java - 避免使用 xslt 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33758535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com