Skip to content

FEAT: Extended conformance validation#270

Merged
carlwilson merged 4 commits intodev/1.18.5from
feat/extended-conformance
Nov 13, 2025
Merged

FEAT: Extended conformance validation#270
carlwilson merged 4 commits intodev/1.18.5from
feat/extended-conformance

Conversation

@carlwilson
Copy link
Member

Many real world ODF documents use foreign XML elements and attributes not defined by the ODF XML schema. This is known as an extended document. This PR provides a pre-processing XML filter that either removes foreign elements, or uses their content, following the rules set out in Section 3.17 of the ODF specification part 3 (Schema).

  • created an ExtendedConformanceFilter, a pre-processing XML filter that resolves the content of foreign elements/attributes or removes them;
  • added a second validation method to XmlValidator that takes any XML filter, this allows use of the extended conformance filter but may be useful for more complex filtered workflows;
  • added an isExtended member variable to OdfValidator and new factory methods to instantiate extended and non-extended versions;
  • added an isExtended member variable to ValidatingParserImpl and new factory methods to instantiate extended and non-extended versions;
  • added an isExtended member variable to ProfileImpl and new factory methods to instantiate extended and non-extended versions;
  • created an extended version of ValidPackageRule so that it supports both forms of validation;
  • fixed reporting of foreign namespaces so they are reported as errors during normal validation, but info messages for extended validation;
  • added EnumSets of OdfNamespaces for the sets of local namespaces for ODF v1.0/1.1 and ODF v1.2 onwards;
  • added tests for extended conformance;
  • added a -e/--extended option to the CLI to invoke extended document validation;
  • tidied up creation of SAX XMLReader and added to XmlUtils class; and
  • added valid and invalid extended documents for testing.

Many real world ODF documents use foreign XML elements and attributes not defined by the ODF XML schema. This is known as an extended document.
This PR provides a pre-processing XML filter that either removes foreign elements, or uses their content, following the rules set out in
[Section 3.17 of the ODF specification part 3 (Schema)](https://docs.oasis-open.org/office/OpenDocument/v1.3/os/part3-schema/OpenDocument-v1.3-os-part3-schema.html#__RefNumPara__623372_981565270).

- created an `ExtendedConformanceFilter`, a pre-processing XML filter that resolves the content of foreign elements/attributes or removes them;
- added a second validation method to `XmlValidator` that takes any XML filter, this allows use of the extended conformance filter but may be useful for more complex filtered workflows;
- added an `isExtended` member variable to `OdfValidator` and new factory methods to instantiate extended and non-extended versions;
- added an `isExtended` member variable to `ValidatingParserImpl` and new factory methods to instantiate extended and non-extended versions;
- added an `isExtended` member variable to `ProfileImpl` and new factory methods to instantiate extended and non-extended versions;
- created an extended version of `ValidPackageRule` so that it supports both forms of validation;
- fixed reporting of foreign namespaces so they are reported as errors during normal validation, but info messages for extended validation;
- added `EnumSets` of `OdfNamespaces` for the sets of local namespaces for ODF v1.0/1.1 and ODF v1.2 onwards;
- added tests for extended conformance;
- added a `-e`/`--extended` option to the CLI to invoke extended document validation;
- tidied up creation of SAX `XMLReader` and added to `XmlUtils` class; and
- added valid and invalid extended documents for testing.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements extended conformance validation for ODF documents that contain foreign XML elements and attributes. The implementation follows Section 3.17 of the ODF specification, adding a preprocessing filter that either removes or processes foreign elements according to the specification rules.

  • Created ExtendedConformanceFilter to handle foreign XML elements/attributes per ODF spec requirements
  • Added isExtended parameter throughout the validation chain (validators, parsers, profiles, rules) to support both standard and extended validation modes
  • Added CLI flag -e/--extended to enable extended document validation via command-line interface

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
extended_valid.xml Test resource: valid extended ODF document with foreign elements
extended_invalid.xml Test resource: invalid extended ODF document for negative testing
ValidPackageRuleTest.java Removed EqualsVerifier test
ProfileImplTest.java Updated to use new API with isExtended parameter
ValidatingParserTest.java Improved null handling by using Path instead of File
PackageParserTest.java Improved null handling by using Path instead of File
TestFiles.java Added constants for new extended conformance test resources
XmlValidatorTest.java Added comprehensive tests for extended conformance validation
OdfSchemaFactory.java Removed overloaded getSchema method that defaulted to ODF_13
OdfNamespaces.java Added EnumSets for ODF 1.0/1.1 and 1.2+ namespace sets
ExtendedConformanceFilter.java New SAX filter implementing extended conformance preprocessing
ValidPackageRule.java Added isExtended parameter to support extended validation mode
Rules.java Added extended profile support and factory methods
ProfileImpl.java Added isExtended member and updated constructors
ValidationResultImpl.java Minor formatting improvement (blank line)
ValidatingParserImpl.java Integrated extended conformance filter and severity adjustments
OdfValidators.java Added factory methods for extended/non-extended validators
OdfValidatorImpl.java Added isExtended support and conditional validation logic
XmlValidator.java Added validate method accepting XMLFilter for filtered validation
XmlUtils.java Added utility methods for creating SAX readers with/without filters
XmlParserImpl.java Refactored to use XmlUtils for SAX reader creation
CliValidator.java Added -e/--extended CLI option for extended validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/**
* Validate the supplied InputStream against the supplied schema.
*
* @param parseResult the {@link ParseResult} obtained form parsign the file
Copy link

Copilot AI Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple typos in JavaDoc comment: "form" should be "from" and "parsign" should be "parsing".

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed minor spelling issues in comments

carlwilson and others added 3 commits November 13, 2025 11:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…xtended_invalid.xml

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Validators.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@carlwilson carlwilson merged commit 898e543 into dev/1.18.5 Nov 13, 2025
5 checks passed
@carlwilson carlwilson deleted the feat/extended-conformance branch November 13, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant