我正在尝试对 edifabric x12 xml 文件进行简单的 xsl 转换。如何选择<D_744_1>
元素?
示例 XML:
<INTERCHANGE xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="www.edifabric.com/x12">
<S_ISA>
<D_744_1>00</D_744_1>
</S_ISA>
</INTERCHANGE>
示例 XSL:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<testfield><xsl:value-of select="INTERCHANGE/S_ISA/D_744_1" /></testfield>
</xsl:template>
</xsl:stylesheet>
结果:
<?xml version="1.0" encoding="utf-8"?>
<testfield/>
期望的结果:
<?xml version="1.0" encoding="utf-8"?>
<testfield>00</testfield>
更新答案感谢@ChriPf:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:edi="www.edifabric.com/x12" exclude-result-prefixes="edi">
<xsl:template match="edi:INTERCHANGE">
<testfield><xsl:value-of select="edi:S_ISA/edi:D_744_1" /></testfield>
</xsl:template>
</xsl:stylesheet>