Closed potatocode420 closed 5 months ago
The xml_namespaces
is not meant to be defined manually, it is automatically decided by the serializer based on namespaces used.
I'm closing the issue, feel free to elaborate more your specific usecase if my answer is not clear enough
but the serializer gets xml_namespaces from the config. without defining xml_namespaces, I am not able to serialize the XML properly.
Below is the result with xml_namespaces:
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ubl="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<ext:UBLExtensions>
<ext:UBLExtension>
<i_d>PHPUNIT</i_d>
</ext:UBLExtension>
</ext:UBLExtensions>
<cbc:ID>PHPUNIT</cbc:ID>
<cbc:Note>Note No. 2!!!</cbc:Note>
<cac:AccountingSupplierParty/>
<cac:AccountingCustomerParty/>
<cac:LegalMonetaryTotal>
<cbc:PayableAmount currencyID="EUR">15.35</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>PHPUNIT</cbc:ID>
<cbc:LineExtensionAmount>555.0</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>PHPUNIT</cbc:Name>
</cac:Item>
</cac:InvoiceLine>
</Invoice>
and the following is without xml_namespaces:
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<ns-d82937bf:UBLExtensions xmlns:ns-d82937bf="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2">
<ns-d82937bf:UBLExtension>
<i_d>PHPUNIT</i_d>
</ns-d82937bf:UBLExtension>
</ns-d82937bf:UBLExtensions>
<ns-e4c2ceaa:ID xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">PHPUNIT</ns-e4c2ceaa:ID>
<ns-e4c2ceaa:Note xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">Note No. 2!!!</ns-e4c2ceaa:Note>
<ns-716b5bb3:AccountingSupplierParty xmlns:ns-716b5bb3="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"/>
<ns-716b5bb3:AccountingCustomerParty xmlns:ns-716b5bb3="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"/>
<ns-716b5bb3:LegalMonetaryTotal xmlns:ns-716b5bb3="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
<ns-e4c2ceaa:PayableAmount xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" currencyID="EUR">15.35</ns-e4c2ceaa:PayableAmount>
</ns-716b5bb3:LegalMonetaryTotal>
<ns-716b5bb3:InvoiceLine xmlns:ns-716b5bb3="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">
<ns-e4c2ceaa:ID xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">PHPUNIT</ns-e4c2ceaa:ID>
<ns-e4c2ceaa:LineExtensionAmount xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">555.0</ns-e4c2ceaa:LineExtensionAmount>
<ns-716b5bb3:Item>
<ns-e4c2ceaa:Name xmlns:ns-e4c2ceaa="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">PHPUNIT</ns-e4c2ceaa:Name>
</ns-716b5bb3:Item>
</ns-716b5bb3:InvoiceLine>
</Invoice>
Hello, is there a way to populate xml_namespaces property for the JMS serializer metadata via the xsd2php configuration? Currently my configuration is generating PHP classes and metadata properly except for the lack of xml_namespaces attribute. For reference, here is my config file: