-
Notifications
You must be signed in to change notification settings - Fork 402
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
Add the Compression element #928
Conversation
Unfortunately this RNC does not work in practice (let me know if I am wrong though, I am no RelaxNG expert).
First of all,
However, using the On a side note, this remote URL: So, I came up with this solution:
This allows the Example tests (trimmed XML for brevity): <EncryptionProperty>
<DummyBefore xmlns="http://www.dummy.org/fake/namespace" attr="val"></DummyBefore>
<Compression xmlns="http://www.idpf.org/2016/encryption#compression" Method="0" OriginalLength="A"></Compression>
</EncryptionProperty> Expected errors:
<EncryptionProperty>
<Compression xmlns="http://www.idpf.org/2016/encryption#compression" Method="9" OriginalLength="0"></Compression>
<DummyAfter xmlns="http://www.dummy.org/fake/namespace" attr="val"></DummyAfter>
</EncryptionProperty> Expected errors:
<EncryptionProperty>
<DummyBefore xmlns="http://www.dummy.org/fake/namespace" attr="val"></DummyBefore>
<DummyAfter xmlns="http://www.dummy.org/fake/namespace" attr="val"></DummyAfter>
</EncryptionProperty> Expected errors:
|
I am responsible for the not-so-easy-to-customize design of xenc-schema.rnc. I was involved in the design of RELAX NG, NVDL, and the RNG schemas for XML security. @danielweck You appear to disallow elder brothers of the Compression element on purpose. Is this backed by the current draft of OCF 3.2? The http URLs do not cause network access because epubcheck use XML catalog (epub30-catalog.xml). So, no changes for schema locations are needed. Finally, I would like to slightly modify the schema for consistency with other security RNG schemas. Here is my proposal.
|
I've updated the pull request per the discussions, but made one change to your suggested schema @murata2makoto. This line:
requires a foreign element, but my understanding of the compression element is that it should be allowed alone. I also can't find anything in the specification that requires the Compression element be in any specific position, so I replaced it with this:
But if either you or @danielweck sees anything wrong with this approach, let me know. |
In fact, I don't think EPUBCheck does use a catalog resolver! As far as I know this catalog file is mostly here to be used by third-party tools, e.g. to configure XML editors. @danielweck the changes made by @mattgarrish look OK to me. Before I mere the PR, Can you confirm the bit about the The only slight change I will make when integrating the PR is running the error assertions before the ones about the error content, to avoid an NPE if only 1 error is found. But that's a detail :-) |
{ | ||
assertTrue(testReport.errorList.get(0).message | ||
.contains("value of attribute \"Method\" is invalid; must be equal to \"0\" or \"8\"")); | ||
assertTrue(testReport.errorList.get(1).message |
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 can possibly throw an NPE since we didn't assert at this point that there are at least two errors…
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.
In fact, I don't think EPUBCheck does use a catalog resolver! As far as I know this catalog file is mostly here to be used by third-party tools, e.g. to configure XML editors.
Then, does epubcheck always retreive schemas?
- update the `ocf-encryption-30.rnc` schema to allow the `Compression` element as a child of `EncryptionProperty` - add tests Fix #904
2bdd330
to
0c9814a
Compare
I may be wrong, but I think it uses local schemas and relative references everywhere. |
This looks good to merge. I opened a separate WIP PR to possibly improve the schema, and most probably to add tests: #978 |
This PR adds the Compression element that was introduced in the 3.1 schema. Fixes #904