-
Notifications
You must be signed in to change notification settings - Fork 9
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
handle the default datatype as no occurrence #5
Conversation
Any datatype should get an ID. If there is an error reporting -1 I think we need to fix the original issue. Can you share the test data that caused this issue? |
It is because in Grammars2X.java in printGrammarProduction I get an attribute in the case ATTRIBUTE that is equal to BuiltIn.DEFAULT_DATATYPE, but this datatype is not added to the listOfSimpleDatatypes at line 198. Here is a XSD reproduction case : <?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="message" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:message="message">
<xs:element name="Message">
</xs:element>
<xs:complexType abstract="true" name="mType">
<xs:attribute name="context" type="xs:string" use="required">
</xs:attribute>
</xs:complexType>
<xs:complexType abstract="true" name="oType">
<xs:attribute name="context" type="message:stoType">
</xs:attribute>
</xs:complexType>
<xs:simpleType name="stoType">
<xs:restriction base="xs:string">
<xs:maxLength value="20"/>
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
</xs:schema> |
@@ -198,7 +198,8 @@ | |||
<!-- global grammar --> | |||
<xs:choice minOccurs="0"> | |||
<!-- global simple-type grammar (if any) --> | |||
<xs:element name="globalSimpleTypeDatatypeID" type="xs:unsignedInt"> | |||
<xs:element name="globalSimpleTypeDatatypeID" type="xs:unsignedInt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed.
@@ -242,7 +243,8 @@ | |||
<xs:element name="attributeNamespaceID" type="xs:unsignedInt"/> | |||
<xs:element name="attributeLocalNameID" type="xs:unsignedInt"/> | |||
<!-- attribute datatype --> | |||
<xs:element name="attributeDatatypeID" type="xs:unsignedInt"/> | |||
<xs:element name="attributeDatatypeID" type="xs:unsignedInt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the only place is needed.
It only happens if there are tow or more attributes with the same name and different type... in elementFragmentGrammar (see https://www.w3.org/TR/exi/#informedElementFragGrammar)
@@ -277,7 +279,8 @@ | |||
<xs:complexType> | |||
<xs:sequence> | |||
<!-- datatype --> | |||
<xs:element name="charactersDatatypeID" type="xs:unsignedInt"/> | |||
<xs:element name="charactersDatatypeID" type="xs:unsignedInt" | |||
minOccurs="0"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minOccurs="0" also not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask you to change the schema just once (in the grammar section) given that this is the only place it should occur...
Thanks!
The default datatype is not added to the listOfSimpleDatatypes, so in an example it was serialized as -1 (the result of indexOf), so I changed the attributeDatatypeID elements to have a minOccurs of 0 and a lack of occurrence means the default datatype.
I updated the PR with your remarks. |
Thanks! I also added your testcase and it seems to work fine. |
The default datatype is not added to the listOfSimpleDatatypes, so in a example it was serialized as -1 (the result of indexOf), so I changed the datatypeID elements to have a minOccurs of 0 and a lack of occurrence means the default datatype. I didn't changed the logic for the globalComplexTypeGrammarID or globalAttributeDatatypeID. I am not exactly sure about them.