Skip to content

Supporting xml_root_prefix #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dyron opened this issue Feb 10, 2025 · 6 comments · May be fixed by #183
Open

Supporting xml_root_prefix #182

dyron opened this issue Feb 10, 2025 · 6 comments · May be fixed by #183

Comments

@dyron
Copy link

dyron commented Feb 10, 2025

While implementing https://www.bzst.de/DE/Unternehmen/Intern_Informationsaustausch/DAC7/dac7_node.html we need the ability to set the xml_root_prefix config (see https://github.com/schmittjoh/serializer/blob/master/src/Metadata/Driver/YamlDriver.php#L383)

Example:

<?xml version="1.0" encoding="UTF-8"?>
<dip:dip version="1.0" xmlns:dip="http://itzbund.de/ozg/bzst/post/dip/v1/" xmlns:dpi="urn:oecd:ties:dpi:v1" xmlns:iso="urn:oecd:ties:isodpitypes:v1" xmlns:stf="urn:oecd:ties:dpistf:v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://itzbund.de/ozg/bzst/post/dip/v1/ dip.xsd ">
    <dip:header environment="TEST">
        <dip:consignment>
            <dip:customerIdentifier>
                <dip:identityProvider>BZST-CERT</dip:identityProvider>
                <dip:identifier>BZ123456789</dip:identifier>
            </dip:customerIdentifier>
            <dip:creationTime>2023-10-01T12:00:00</dip:creationTime>
            <dip:transferticketId>09dedc8e-d2f8-4293-ad9e-9b50abce961c</dip:transferticketId>
        </dip:consignment>
        <dip:application code="DAC7"/>
    </dip:header>
    <dip:body>
        <dip:consignmentItem>
            <dip:data>
                <dpi:DPI_OECD version="1.0" xsi:schemaLocation="urn:oecd:ties:dpi:v1 DPIXML_v1.0.xsd " />
            </dip:data>
        </dip:consignmentItem>
    </dip:body>
</dip:dip>

dyron added a commit to conlabz/xsd2php that referenced this issue Feb 10, 2025
@dyron dyron linked a pull request Feb 10, 2025 that will close this issue
@goetas
Copy link
Member

goetas commented Feb 13, 2025

Why a specific prefix is important? If the namespace for a generated prefix is correct, any "good" xml parser should work well with it

@dyron
Copy link
Author

dyron commented Feb 14, 2025

The lib haven't generated a prefix at all yet.

xmlns:dip="http://itzbund.de/ozg/bzst/post/dip/v1/" doesn't result in dip: or xmlns:dpi="urn:oecd:ties:dpi:v1" doesn't in dpi:.

I try to match an example xml provided by the xsd author in a test and the prefixes are present. So I thought they are mandatory, aren't they?

@goetas
Copy link
Member

goetas commented Feb 14, 2025 via email

@dyron
Copy link
Author

dyron commented Feb 14, 2025

Expected xml:

<?xml version="1.0" encoding="UTF-8"?>
<dip:dip version="1.0" xmlns:dip="http://itzbund.de/ozg/bzst/post/dip/v1/" xmlns:dpi="urn:oecd:ties:dpi:v1" xmlns:iso="urn:oecd:ties:isodpitypes:v1" xmlns:stf="urn:oecd:ties:dpistf:v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://itzbund.de/ozg/bzst/post/dip/v1/ dip.xsd ">
  <dip:header environment="TEST">
    <dip:consignment>
      <dip:customerIdentifier>
        <dip:identityProvider>BZST-CERT</dip:identityProvider>
        <dip:identifier>BZ123456789</dip:identifier>
      </dip:customerIdentifier>
      <dip:creationTime>2023-10-01T12:00:00</dip:creationTime>
      <dip:transferticketId>09dedc8e-d2f8-4293-ad9e-9b50abce961c</dip:transferticketId>
    </dip:consignment>
    <dip:application code="DAC7"/>
  </dip:header>
  <dip:body>
    <dip:consignmentItem>
      <dip:data>
        <dpi:DPI_OECD version="1.0" xsi:schemaLocation="urn:oecd:ties:dpi:v1 DPIXML_v1.0.xsd ">
          <dpi:MessageSpec>
            <dpi:SendingEntityIN>1234567891011</dpi:SendingEntityIN>
            <dpi:TransmittingCountry>DE</dpi:TransmittingCountry>
            <dpi:ReceivingCountry>DE</dpi:ReceivingCountry>
            <dpi:MessageType>DPI</dpi:MessageType>
            <dpi:MessageRefId>DE2023DE-c0d5e394-e264-4dc7-9e51-c57b6a638ae5
            </dpi:MessageRefId>
            <dpi:MessageTypeIndic>DPI401</dpi:MessageTypeIndic>
            <dpi:ReportingPeriod>2023-12-31</dpi:ReportingPeriod>
            <dpi:Timestamp>2022-12-15T09:45:30</dpi:Timestamp>
          </dpi:MessageSpec>
          <dpi:DPIBody>
            <dpi:PlatformOperator>
              <dpi:ResCountryCode>DE</dpi:ResCountryCode>
              <dpi:TIN issuedBy="DE">1234567891011
              </dpi:TIN>
              <dpi:Name>Plattformbetreiber GmbH</dpi:Name>
              <dpi:PlatformBusinessName>Testplattform</dpi:PlatformBusinessName>
              <dpi:Address legalAddressType="OECD304">
                <dpi:CountryCode>DE</dpi:CountryCode>
                <dpi:AddressFix>
                  <dpi:Street>Plattformbetreiberstraße</dpi:Street>
                  <dpi:BuildingIdentifier>2</dpi:BuildingIdentifier>
                  <dpi:PostCode>12345</dpi:PostCode>
                  <dpi:City>Plattformbetreiberstadt</dpi:City>
                </dpi:AddressFix>
              </dpi:Address>
              <dpi:Nexus>RPONEX1</dpi:Nexus>
              <dpi:AssumedReporting>false</dpi:AssumedReporting>
              <dpi:DocSpec>
                <stf:DocTypeIndic>OECD1</stf:DocTypeIndic>
                <stf:DocRefId>DE2023-d5c4c49b-79bc-4b22-a6cd-3f45cfd801f3</stf:DocRefId>
              </dpi:DocSpec>
            </dpi:PlatformOperator>
          </dpi:DPIBody>
        </dpi:DPI_OECD>
      </dip:data>
    </dip:consignmentItem>
  </dip:body>
</dip:dip>

Actual

<?xml version="1.0" encoding="UTF-8"?>
<dip xmlns="http://itzbund.de/ozg/bzst/post/dip/v1/" version="1.0">
 <header environment="TEST">
   <consignment>
     <customerIdentifier>
       <identityProvider>BZST-CERT</identityProvider>
       <identifier>BZ123456789</identifier>
     </customerIdentifier>
     <creationTime>2023-10-01T12:00:00</creationTime>
     <transferticketId>09dedc8e-d2f8-4293-ad9e-9b50abce961c</transferticketId>
   </consignment>
   <application code="DAC7"/>
 </header>
 <body>
   <consignmentItem>
     <data version="1.0">
       <ns-0648b7ac:MessageSpec xmlns:ns-0648b7ac="urn:oecd:ties:dpi:v1">
         <ns-0648b7ac:SendingEntityIN>1234567891011</ns-0648b7ac:SendingEntityIN>
         <ns-0648b7ac:TransmittingCountry>DE</ns-0648b7ac:TransmittingCountry>
         <ns-0648b7ac:ReceivingCountry>DE</ns-0648b7ac:ReceivingCountry>
         <ns-0648b7ac:MessageType>DPI</ns-0648b7ac:MessageType>
         <ns-0648b7ac:MessageRefId>DE2023DE-c0d5e394-e264-4dc7-9e51-c57b6a638ae5</ns-0648b7ac:MessageRefId>
         <ns-0648b7ac:MessageTypeIndic>DPI401</ns-0648b7ac:MessageTypeIndic>
         <ns-0648b7ac:ReportingPeriod>2023-12-31</ns-0648b7ac:ReportingPeriod>
         <ns-0648b7ac:Timestamp>2022-12-15T09:45:30</ns-0648b7ac:Timestamp>
       </ns-0648b7ac:MessageSpec>
       <ns-0648b7ac:DPIBody xmlns:ns-0648b7ac="urn:oecd:ties:dpi:v1">
         <ns-0648b7ac:PlatformOperator>
           <ns-0648b7ac:ResCountryCode>DE</ns-0648b7ac:ResCountryCode>
           <ns-0648b7ac:TIN issuedBy="DE">1234567891011</ns-0648b7ac:TIN>
           <ns-0648b7ac:Name>Plattformbetreiber GmbH</ns-0648b7ac:Name>
           <ns-0648b7ac:PlatformBusinessName>Testplattform</ns-0648b7ac:PlatformBusinessName>
           <ns-0648b7ac:Address>
             <ns-0648b7ac:CountryCode>DE</ns-0648b7ac:CountryCode>
             <ns-0648b7ac:AddressFix>
               <ns-0648b7ac:Street>Plattformbetreiberstraße</ns-0648b7ac:Street>
               <ns-0648b7ac:BuildingIdentifier>2</ns-0648b7ac:BuildingIdentifier>
               <ns-0648b7ac:PostCode>12345</ns-0648b7ac:PostCode>
               <ns-0648b7ac:City>Plattformbetreiberstadt</ns-0648b7ac:City>
             </ns-0648b7ac:AddressFix>
           </ns-0648b7ac:Address>
           <ns-0648b7ac:Nexus>RPONEX1</ns-0648b7ac:Nexus>
           <ns-0648b7ac:AssumedReporting>false</ns-0648b7ac:AssumedReporting>
           <ns-0648b7ac:DocSpec>
             <ns-cb0da4ea:DocTypeIndic xmlns:ns-cb0da4ea="urn:oecd:ties:dpistf:v1">OECD1</ns-cb0da4ea:DocTypeIndic>
             <ns-cb0da4ea:DocRefId xmlns:ns-cb0da4ea="urn:oecd:ties:dpistf:v1">DE2023-d5c4c49b-79bc-4b22-a6cd-3f45cfd801f3</ns-cb0da4ea:DocRefId>
           </ns-0648b7ac:DocSpec>
         </ns-0648b7ac:PlatformOperator>
       </ns-0648b7ac:DPIBody>
     </data>
   </consignmentItem>
 </body>
</dip>

Current config.yml

xsd2php:
  namespaces:
    'http://itzbund.de/ozg/bzst/post/dip/v1/': 'My\Namespace\Dip'
    'urn:oecd:ties:dpi:v1': 'My\Namespace\DAC7'
    'urn:oecd:ties:dpistf:v1': 'My\Namespace\DAC7\Types\Oecd'
    'urn:oecd:ties:isodpitypes:v1': 'My\Namespace\DAC7\Types\Iso'
  destinations_php:
    'My\Namespace': src
  destinations_jms:
    'My\Namespace': metadata
  known_locations: # optional
    'http://itzbund.de/ozg/bzst/post/dip/v1/': xsd/dip.xsd
  known_namespace_locations: # optional
    'urn:oecd:ties:dpi:v1': 'xsd/DAC7/DPI7DPIXML_v1.08.xsd'
    'urn:oecd:ties:dpistf:v1': xsd/DAC7/oecddpitypes_v1.0.xsd
    'urn:oecd:ties:isodpitypes:v1': xsd/DAC7/isodpitypes_v1.0.xsd
  configs_jms:  #optional
    xml_cdata: false # Disables CDATA
  aliases: # optional
    'http://www.w3.org/2001/XMLSchema':
      anyType: 'My\Namespace\UserDataHandler'

@goetas
Copy link
Member

goetas commented Feb 14, 2025

Both document semantically are the same.

<dip xmlns="http://itzbund.de/ozg/bzst/post/dip/v1/" version="1.0"> and <dip:dip xmlns:dip="http://itzbund.de/ozg/bzst/post/dip/v1/" version="1.0"> are exactly the same thing.

https://3v4l.org/OkNIs

Are you sure the "other part" has a decent xml implementation?

@dyron
Copy link
Author

dyron commented Feb 18, 2025

Are you sure the "other part" has a decent xml implementation?

No, but I'll give it a try. Since it's a government institution I expect to match the provided example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants