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

Assumes that all "Enumeration" Types have an integer BaseType and raises an Exception otherwise #119

Closed
thomasheritage opened this issue Feb 14, 2018 · 5 comments

Comments

@thomasheritage
Copy link
Contributor

Sample output (from an old version of the code, but the relevant parts don't look like they've changed):

Exception in thread "main" java.lang.NumberFormatException: For input string: "Main"
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
        at java.lang.Integer.parseInt(Integer.java:580)
        at java.lang.Integer.valueOf(Integer.java:740)
        at java.lang.Integer.decode(Integer.java:1197)
        at com.sandflow.smpte.regxml.dict.importers.RegisterImporter.fromRegister(RegisterImporter.java:389)
        at com.sandflow.smpte.tools.XMLRegistersToDict.main(XMLRegistersToDict.java:86)

This occurs when processing a Types Register that contains a Type with TypeKind "Enumeration" where a Facet Value is not an Integer. This will legitimately occur in the Types Register when the BaseType of the Type is a non-Integer Type.

SMPTE ST 2003:2012 Section 4.2.2 is clear that Enumerations can have any BaseType. This also the practical approach taken in managing the Types Register, as documented at https://registry.smpte-ra.org/view/draft/docs/Register%20(Types)/Type%20Kinds/Enumeration/

Therefore, regxmllib needs to expect such types when processing a Types Register and not raise an Exception.

However, SMPTE ST 2001-1:2013 Section 6.1.6 is clear that an Enumeration always has integer values.

Perhaps the best approach is for regxmllib to simply ignore any entries in the Types Register which cannot be mapped to Reg-XML.

@palemieux
Copy link
Contributor

palemieux commented Feb 15, 2018

An “Enumeration” Type can have any BaseType.

Well, how is any BaseType supposed to be represented as an xs:string which is the type of the facet value in the XML registers?

Therefore, regxmllib needs to expect such types when processing a Types Register and not raise an Exception.

Yes. This should be fixed.

@palemieux
Copy link
Contributor

@thomasheritage Please review PR #120

@palemieux palemieux added the java label Feb 15, 2018
@thomasheritage
Copy link
Contributor Author

Thanks a lot for the quick alteration -- I'll test shortly.

Well, how is any BaseType supposed to be represented as an xs:string which is the type of the facet value in the XML registers?

As per the Registers docs this is currently only defined for a couple of cases -- in other cases the representation is not guaranteed to take any particular form. The only case so far is an Enumeration with a BaseType of string so this isn't an issue.

@palemieux
Copy link
Contributor

in other cases the representation is not guaranteed to take any particular form.

It should therefore be forbidden until someone makes the effort to propose something.

The only case so far is an Enumeration with a BaseType of string so this isn't an issue.

This is not documented anywhere, e.g. at the Registers docs

@palemieux
Copy link
Contributor

palemieux commented Feb 25, 2018

@thomasheritage Any luck on the testing? Thanks! If so, can you approve the PR?

palemieux added a commit that referenced this issue Mar 20, 2018
Prune properties that use undefined types
Add Metadictionay XSD generation tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants