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

Unit has at least one <segment> or <ignorable> #31

Closed
MaximBrain opened this issue May 19, 2019 · 8 comments
Closed

Unit has at least one <segment> or <ignorable> #31

MaximBrain opened this issue May 19, 2019 · 8 comments

Comments

@MaximBrain
Copy link

MaximBrain commented May 19, 2019

Hi.
I just started using this lib and found one strange exception that doesn't correspond with the documentation http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html.

Unit tag has "at least one of ( OR )"? As a result, I get an exception with the following type of xlif file:

------------------------------------------
<unit id="Product">
	<ignorable>
		<source>Product Source</source>
	</ignorable>
</unit>
------------------------------------------

I can fix this issue, and deliver code. Are you okay with this?

@simonech
Copy link
Contributor

simonech commented May 19, 2019 via email

@MaximBrain
Copy link
Author

Hi,
Thanks for the quick response

  1. There is example with all xliff tree:
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:2.0" version="2.0" srcLang="en-US" trgLang="sv-SE">
    <file id="SomeID">
        <group id="_system">
            <unit id="Unit1">
                <ignorable>
                    <source>3213</source>
                </ignorable>
            </unit>

In this case, we get exception with the following error message: "The element must contain one or more Segment"

  1. In "4.2.1 Tree Structure" paragraph in http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html documentation, the Standard says that "Unit can have at least one of (segment OR ignorable)"

Same you can find in 4.2.2.5 unit paragraph - "One or more segment or ignorable elements in any order."

  1. The following place throws the exception: "StandardValidator.cs file, 4186 line"

And the problem is in the same file with 4126 line: hasSegment |= container is Segment;
We can rename this variable to hadChildren and refactor code with the following example:

hadChildren = unit.Resources.Count > 0

@simonech
Copy link
Contributor

simonech commented May 20, 2019 via email

@simonech
Copy link
Contributor

@MaximBrain just double checked.
If you read carefully, there is a constraint:

A <unit> MUST contain at least one <segment> element.

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

So, validation from this library is correct.

@DavidFatDavidF
Copy link

Hi @MaximBrain, @simonech

This library, Okapi Lynx, and XLIFF Core Schematrons all correctly catch this as invalid.
http://docs.oasis-open.org/xliff/xliff-core/v2.1/xliff-core-v2.1.html#unit
http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html#unit
In general the spec first describes the grammar as expressible in W3C Schema and then gives any additional business logic constraints or requirements under Constraints or Processing Requirements (depending on whether they are static or dynamic):
Under unit it says explicitly:

Constraints
A <unit> MUST contain at least one <segment> element.

@simonech
Copy link
Contributor

Thx @DavidFatDavidF for the explanation

too bad we cannot close the issue 😄

@MaximBrain
Copy link
Author

Hi,

Strange, documentation has different explained behavior
Anyway, thanks for the explanation
I'll close this issue

@simonech
Copy link
Contributor

simonech commented May 20, 2019 via email

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

3 participants