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

xs:enumeration is not translated correctly to annotations #41

Closed
asakelliou opened this issue Nov 6, 2015 · 8 comments
Closed

xs:enumeration is not translated correctly to annotations #41

asakelliou opened this issue Nov 6, 2015 · 8 comments

Comments

@asakelliou
Copy link

Give the following piece of an xsd :

        <xsd:enumeration value="12" />
        <xsd:enumeration value="13" />
        <xsd:enumeration value="14" />
        <xsd:enumeration value="15" />
        <xsd:enumeration value="19" />
        <xsd:enumeration value="26" />
        <xsd:enumeration value="35" />
        <xsd:enumeration value="37" />
        <xsd:enumeration value="38" />
        <xsd:enumeration value="39" />
        <xsd:enumeration value="40" />
        <xsd:enumeration value="90" />
        <xsd:enumeration value="91" />
        <xsd:enumeration value="92" />
        <xsd:enumeration value="93" />

the translated annotations are :

@Pattern.List({
@pattern(regexp = "12"),
@pattern(regexp = "13"),
@pattern(regexp = "14"),
@pattern(regexp = "15"),
@pattern(regexp = "19"),
@pattern(regexp = "26"),
@pattern(regexp = "35"),
@pattern(regexp = "37"),
@pattern(regexp = "38"),
@pattern(regexp = "39"),
@pattern(regexp = "40"),
@pattern(regexp = "90"),
@pattern(regexp = "91"),
@pattern(regexp = "92"),
@pattern(regexp = "93")
})

Which of course is wrong because the given value must satisfy all the patterns in the list at the same time.

@ST-DDT
Copy link
Contributor

ST-DDT commented Jan 10, 2016

@asakelliou Are you sure?
AFAIK this must only fullfill one instead of all.
Do you have some official documentation that supports your theses.
I didn't found anything on this topic though.

@asakelliou
Copy link
Author

When I had this code (I have transformed the field to enumeration througf jaxb.xjb), when it was validated against a single value (ie "93"), I got 14 validation errors that informed me of wrong pattern, each with the pattern from the list. If you really need the error messages, let me know and I will try re recreate them sometime in the future.

@StefanS
Copy link
Contributor

StefanS commented Feb 15, 2016

Hi,
this issue affects me too.

Given xsd part :

<element name="sex" minOccurs="0">
      <simpleType>
           <restriction base="{http://www.w3.org/2001/XMLSchema}string">
                <enumeration value="f"/>
                <enumeration value="m"/>
            </restriction>
      </simpleType>
</element>

generated java class part:

 @Pattern.List({
       @Pattern(regexp = "f"),
       @Pattern(regexp = "m")
 })
 protected String sex;

xml with:
<sex>m</sex>
leads to message:
'muss auf Ausdruck "f" passen' (german for must match expression 'f')

xml with:
<sex>f</sex>
leads to message:
'muss auf Ausdruck "m" passen' (german for must match expression 'm')

For the validation I used 'org.hibernate:hibernate-validator:5.2.2.Final'

StefanS added a commit to StefanS/krasa-jaxb-tools that referenced this issue Feb 16, 2016
@mschaefers
Copy link

This problem affects me as well. I strongly suggest to create a pull request for this, @StefanS

@martinsznapka
Copy link

I have exactly same issue. Pattern.List constraint is evaluated as AND for each Pattern, so validating enumeration always fail.

@krasa Can you please accept merge request from @StefanS
Díky ;)

@krasa krasa closed this as completed in e0aaabd Jun 24, 2016
@krasa
Copy link
Owner

krasa commented Jun 24, 2016

I am currently on remote location without my dev PC, so I cannot test it and release it, but I will be back in a week or so.. :-)

@martinsznapka
Copy link

Ok, np, thx.
BTW the patch works correctly. It generates:
@Pattern(regexp = "(enumvalue1)|(enumvalue2)|(enumvalue3)")

@krasa
Copy link
Owner

krasa commented Jul 1, 2016

1.5 released.

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

No branches or pull requests

6 participants