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

handle the default datatype as no occurrence #5

Merged
merged 1 commit into from
Sep 27, 2017

Conversation

amarant
Copy link
Contributor

@amarant amarant commented Sep 22, 2017

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.

@danielpeintner
Copy link
Member

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?

@amarant
Copy link
Contributor Author

amarant commented Sep 26, 2017

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"
Copy link
Member

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"
Copy link
Member

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"/>
Copy link
Member

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.

Copy link
Member

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.
@amarant
Copy link
Contributor Author

amarant commented Sep 26, 2017

I updated the PR with your remarks.

@danielpeintner danielpeintner merged commit 365cde7 into EXIficient:master Sep 27, 2017
danielpeintner added a commit that referenced this pull request Sep 27, 2017
@danielpeintner
Copy link
Member

Thanks! I also added your testcase and it seems to work fine.

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.

None yet

2 participants