0

我有一个 .xslt 文件,但它没有给出任何结果。我想我错过了一些命名空间或其他东西,但我没有看到问题。

XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<xsl:template match="/">
<DataSet>
    <ifch.t_factuurnr><xsl:value-of select="Invoice/cbc:ID"/></ifch.t_factuurnr>
</DataSet>
</xsl:template>
</xsl:stylesheet>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2 http://docs.oasis-open.org/ubl/os-UBL-2.1/xsd/maindoc/UBL-Invoice-2.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <cbc:UBLVersionID>2.1</cbc:UBLVersionID>
    <cbc:ID>200858</cbc:ID>
</Invoice>

谁能告诉我我错过了什么?

4

1 回答 1

0

我必须在我的命名空间中添加一个 :... :wix ,但是是否可以不声明命名空间并将所有内容都放在第一个节点中?

<xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<xsl:template match="/">

变成:

<xmlns:wix="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<xsl:template match="/">
<ifch.t_factuurnr><xsl:value-of select="wix:Invoice/cbc:ID"/></ifch.t_factuurnr>
于 2020-06-12T05:40:29.643 回答