net.sf.okapi.lib.xliff2.metadata.Meta.setType() should accept empty strings

Issue #20 resolved
Nikolai Weibull created an issue

The type attribute on mda:meta isn’t limited to non-empty strings, so checking that its value isn’t empty isn’t right. The patch for this is simple, just change the test to

type == null

on line 69 of Meta.java, see

https://bitbucket.org/okapiframework/xliff-toolkit/src/860e31edac03cb4a36cca334efe036b2497f1211/okapi/libraries/lib-xliff/src/main/java/net/sf/okapi/lib/xliff2/metadata/Meta.java?at=dev&fileviewer=file-view-default#Meta.java-69

For further reference, see the XML Schema for mda:meta,

http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html#metadata_schema

The relevant part is

  <xs:element name="meta">
    <xs:complexType mixed="true">
      <xs:attribute name="type" use="required" type="xs:string"/>
    </xs:complexType>
  </xs:element>

and, as I’m sure you know, this doesn’t limit type to non-empty strings. The type would have to be something along the lines of

<simpleType name="non-empty-string">
  <restriction base="xs:string">
    <minLength value="1"/>
  </restriction>
</simpleType>

for that to be the case.

Now I haven’t looked at the rest of the code that uses Meta.getType() to verify that no callers expect a non-empty string. I assume that you know where to look to apply any further necessary patches. The comments on line 32 and line 40 should be updated to reflect that type must only be non-null.

Thank you!

Nikolai

Comments (3)

  1. Log in to comment