xmlxsltubl

xslt for ubl xml don't get any value


I have a .xslt file but it doesn't give any result. I think i'm missing some namespace or something but i don't see the problem.

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>

Can anyone tell me what i'm missing?


Solution

  • I had to add a :... :wix to my namespaces, but is it possible to just don't declare the namespace and take everything inside the first node?

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

    changed to:

    <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>