Skip to content
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

Invalid prefix for Compas Privates when marshalling #287

Closed
massifben opened this issue Jun 9, 2023 · 0 comments · Fixed by #288
Closed

Invalid prefix for Compas Privates when marshalling #287

massifben opened this issue Jun 9, 2023 · 0 comments · Fixed by #288
Labels
bug Something isn't working

Comments

@massifben
Copy link
Contributor

Subject of the issue

When marshalling Compas Privates (JAXB objects generated by SCL_CoMPAS.xsd), the marshaller generate a prefix "ns2" instead of "compas" for these element

Steps to reproduce

Execute this test

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TCompasSclFileType;
import org.lfenergy.compas.scl2007b4.model.THeader;
import org.lfenergy.compas.scl2007b4.model.TPrivate;
import org.lfenergy.compas.sct.commons.scl.PrivateService;
import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper;

class IssueTest {

    @Test
    void marshallCompasPrivate(){
        // Given
        SCL scl = createValidScl();
        TPrivate aCompasPrivate = PrivateService.createPrivate(TCompasSclFileType.SCD);
        scl.getPrivate().add(aCompasPrivate);
        // When
        String result = MarshallerWrapper.marshall(scl);
        // Then
        System.out.println(result);
        Assertions.assertThat(result).contains("compas:");
    }

    private static SCL createValidScl() {
        SCL scl = new SCL();
        scl.setVersion("2007");
        scl.setRevision("B");
        scl.setRelease((short) 4);
        THeader tHeader = new THeader();
        tHeader.setId("headerId");
        scl.setHeader(tHeader);
        return scl;
    }
}

Expected behaviour

Test should pass.
Output should be :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SCL version="2007" revision="B" release="4" xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:compas="https://www.lfenergy.org/compas/extension/v1">
    <Private type="COMPAS-SclFileType">
        <compas:SclFileType>SCD</compas:SclFileType>
    </Private>
    <Header id="headerId"/>
</SCL>

The namespace "https://www.lfenergy.org/compas/extension/v1" should have prefix "compas".

Actual behaviour

Test fails
Output is:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SCL version="2007" revision="B" release="4" xmlns="http://www.iec.ch/61850/2003/SCL" xmlns:ns2="https://www.lfenergy.org/compas/extension/v1">
    <Private type="COMPAS-SclFileType">
        <ns2:SclFileType>SCD</ns2:SclFileType>
    </Private>
    <Header id="headerId"/>
</SCL>

The namespace "https://www.lfenergy.org/compas/extension/v1" has prefix "ns2".

@massifben massifben added the bug Something isn't working label Jun 9, 2023
massifben added a commit that referenced this issue Jun 9, 2023
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
massifben added a commit that referenced this issue Jun 9, 2023
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
massifben added a commit that referenced this issue Jun 9, 2023
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
massifben added a commit that referenced this issue Jun 9, 2023
Signed-off-by: massifben <105049157+massifben@users.noreply.github.com>
massifben added a commit that referenced this issue Jun 9, 2023
…s_privates_when_marshalling

fix(#287): fix invalid prefix for Compas Privates when marshalling
samirromdhani pushed a commit to samirromdhani/compas-sct that referenced this issue Jun 15, 2023
…r_compas_privates_when_marshalling

fix(com-pas#287): fix invalid prefix for Compas Privates when marshalling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant