Skip to content

Fix Namespace Handling in XML Serialization with Updated package-info.java #2

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
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

zabuTNT
Copy link

@zabuTNT zabuTNT commented Apr 18, 2024

This pull request updates the package-info.java in the de.vdv.ojp.model package to correctly define namespace prefixes, ensuring proper namespace handling during the XML serialization process. The modifications include setting specific namespace prefixes and ensuring that the XML output is compliant with the defined schemas.

Changes Made:

  • Updated package-info.java to include @XmlNs
  • Specified namespace prefixes for each required namespace to ensure that elements are properly qualified in the resulting XML.

Benefits:

  • Ensures XML output is consistent with external XSD expectations and prevents serialization errors.
  • Improves compatibility with XML consumers expecting correctly namespaced elements.

Before:

<OJP xmlns="http://www.siri.org.uk/siri" xmlns:ns2="http://www.vdv.de/ojp" xmlns:ns4="http://www.ifopt.org.uk/ifopt" xmlns:ns3="http://www.ifopt.org.uk/acsb">
    <OJPResponse>
        <ServiceDelivery>
            <ResponseTimestamp>2024-04-18T14:06:58+02:00</ResponseTimestamp>
            <ProducerRef>OpenTripPlanner</ProducerRef>
            <Status>true</Status>
            <ns2:OJPLocationInformationDelivery>
                <Status>true</Status>
                <ns2:CalcTime>31</ns2:CalcTime>...

After:

<siri:OJP xmlns:ifopt="http://www.ifopt.org.uk/ifopt" xmlns:ojp="http://www.vdv.de/ojp" xmlns:siri="http://www.siri.org.uk/siri" xmlns:acsb="http://www.ifopt.org.uk/acsb">
    <siri:OJPResponse>
        <siri:ServiceDelivery>
            <siri:ResponseTimestamp>2024-04-18T15:40:58+02:00</siri:ResponseTimestamp>
            <siri:ProducerRef>OpenTripPlanner</siri:ProducerRef>
            <siri:Status>true</siri:Status>
            <ojp:OJPLocationInformationDelivery>
                <siri:Status>true</siri:Status>
                <ojp:CalcTime>29</ojp:CalcTime>
                <ojp:Location>
                    <ojp:Location>
                        <ojp:StopPoint>
                            <siri:StopPointRef>sta:it:22021:952:0:1438</siri:StopPointRef>
                            <ojp:StopPointName>...

@skinkie
Copy link
Contributor

skinkie commented Feb 7, 2025

I disagree that the namespace is wrong. There are vendors not able to handling other default namespaces than they have implemented.

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 this pull request may close these issues.

2 participants