This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A Java library for validating NeTEx (Network Timetable Exchange) datasets against the Nordic NeTEx Profile. Used by Antu for Entur-specific validation. Published to Maven Central as org.entur:netex-validator-java.
# Build (skip prettier during development)
mvn install -Dprettier.skip=true
# Run all tests (skip prettier)
mvn test -Dprettier.skip=true
# Run a single test class
mvn test -Dprettier.skip=true -Dtest=ClassName
# Run a single test method
mvn test -Dprettier.skip=true -Dtest=ClassName#methodName
# Format code with prettier (run before committing)
mvn prettier:write
# Check formatting only (CI mode)
mvn validate -P prettierCheckJava 17 is required. The project uses prettier-java for code formatting (runs in the validate phase by default). Use -Dprettier.skip=true to skip formatting during development.
NetexValidatorsRunner orchestrates validation in three sequential, blocking phases:
- Schema Validation (
NetexSchemaValidator) - XML Schema validation. If errors found, stops here. - XPath Validation (
XPathValidatorimplementations) - XPath queries on Saxon XDM tree. If errors found, stops here. - JAXB Validation (
JAXBValidatorimplementations) - Validation using JAXB object model (NetexEntitiesIndexfrom netex-parser-java). Runs only if prior phases pass.
After all files are processed, Dataset Validators (DatasetValidator) run cross-file validations.
NetexValidator<V extends ValidationContext>- Base validator interface. ReturnsList<ValidationIssue>.XPathValidator- Marker interface extendingNetexValidator<XPathValidationContext>.JAXBValidator- Marker interface extendingNetexValidator<JAXBValidationContext>.DatasetValidator- Cross-file validation after all individual files are processed.NetexDataCollector- Collects data from individual files for use by dataset validators.
Each rule is a ValidationRule(code, name, message, severity). Validators return ValidationIssue instances referencing a rule and a DataLocation. The ValidationReportEntryFactory converts issues to report entries, supporting configuration-based override of severity/name/message via YAML.
XPath rules are organized in a ValidationTree hierarchy (see validator/xpath/tree/ for defaults). Generic rule implementations in validator/xpath/rules/:
ValidateNotExist- Asserts an XPath returns no resultsValidateAtLeastOne- Asserts at least one matchValidateExactlyOne- Asserts exactly one match
XPathRuleValidator takes a ValidationTreeFactory and evaluates the tree against each file.
CommonDataRepository/CommonDataRepositoryLoader- Stores data from common files (prefixed with_) for use when validating line files.StopPlaceRepository- Provides stop place/quay data for validators needing geographic context.NetexDataRepository- Collects data per-file viaNetexDataCollectorfor cross-file dataset validation.
cli/- Command-line interface (NetexValidatorCLI,validate-netex.sh)configuration/- YAML-based rule configuration overridevalidator/- Core interfaces and runnervalidator/xpath/- XPath-based validation (rules, tree structure)validator/jaxb/- JAXB-based validation (object model navigation)validator/id/- NeTEx ID extraction and uniqueness checkingvalidator/schema/- XML Schema validationvalidator/model/- Domain value types (QuayId, ServiceJourneyId, etc.)xml/- XML parsing utilities (Saxon-basedNetexXMLParser)
Shared test helpers are in src/test/java/org/entur/netex/validation/test/ and packaged as a test JAR for downstream projects:
test/xpath/support/TestValidationContextBuilder- Builds XPath validation contexts from XML stringstest/jaxb/support/JAXBUtils- JAXB test utilities
- Datasets are ZIP files containing XML files
- Common/shared files are prefixed with
_ - Each non-common file represents a single NeTEx Line
- Common files are validated first; their data is collected for use during line file validation
Follows semantic versioning. Version bumps are managed via gitflow-maven-plugin.