Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Build and Deploy
on:
workflow_dispatch:
push:
branches:
- 1.x
- upgrade-netex-2.0_for_1.x
pull_request:
branches:
- 1.x
- upgrade-netex-2.0_for_1.x
jobs:
maven-verify:
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -52,7 +53,7 @@ jobs:

publish-snapshot:
name: Publish snapshot to Maven Central
if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/1.x'
if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/upgrade-netex-2.0_for_1.x'
needs: maven-verify
uses: ./.github/workflows/maven-jreleaser-release.yml
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:

- uses: actions/setup-java@v4
with:
java-version: 11
distribution: liberica
java-version: 8
distribution: temurin
cache: maven

- name: Install xmlstarlet
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
profile
.idea
*.iml
Expand Down
17 changes: 10 additions & 7 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

**netex-java-model** is a Java library that generates JAXB model classes from NeTEx (Network Timetable Exchange) XML Schema Definition (XSD) files. The XSD files are downloaded from https://github.com/entur/NeTEx and compiled into Java classes at build time.
**netex-java-model** (Maven coordinates `org.entur:netex-java-model`, 1.x line) is a Java library that generates JAXB model classes from NeTEx (Network Timetable Exchange) XML Schema Definition (XSD) files. The NeTEx 2.0 XSD is downloaded from https://github.com/TransmodelEcosystem/NeTEx and compiled into Java classes at build time. The legacy schemas used only for validation (1.04beta - 1.16.1) are downloaded from the Entur fork at https://github.com/entur/NeTEx.

The 1.x branch targets Java 8 and Java EE 8 (`javax.xml.bind`, JAXB 2.3); the Jakarta EE line of the library lives on `master`.

- **Organization**: Entur AS (Norwegian public transport data provider)
- **License**: EUPL-1.2
- **Java Version**: 8 (builds on 8 in CI)
- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex` and `org.rutebanken.util` (source)
- **Java Version**: 8 (builds and publishes on 8 in CI)
- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex`, `org.rutebanken.netex.client`, `org.rutebanken.netex.validation` and `org.rutebanken.util` (source). GML and SIRI types are generated in `net.opengis.gml._3` and `uk.org.siri.siri`.

## Build Commands

Expand Down Expand Up @@ -48,20 +50,21 @@ mvn validate
## Key Technical Details

- **JAXB Bindings**: The `bindings.xjb` file customizes code generation, including:
- Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`)
- Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`)
- Property name conflict resolution
- Package naming (`org.rutebanken.netex.model`)
- A generated block (between `BEGIN/END generated _Dummy bindings` markers) that hides the `_Dummy` suffix of the abstract substitution-group heads: `getDayType()` instead of `getDayType_Dummy()`, `createDayType_(...)` in `ObjectFactory`. Do not edit the block by hand; rerun `bin/generate-dummy-bindings.py src/main/resources/xsd/<version>/NeTEx_publication.xsd bindings.xjb` after a schema upgrade.

- **Generated Code**: Model classes are generated in `target/generated-sources/` during build. Do not manually edit generated code.

- **NeTEx Version**: Configured in `pom.xml` via `<netexVersion>` property (currently 1.16).
- **NeTEx Version**: Configured in `pom.xml` via `<netexVersion>` property (currently 2.0).

- **Validation**: `NeTExValidator` class provides XML schema validation against NeTEx XSD.
- **Validation**: `NeTExValidator` class provides XML schema validation against NeTEx XSD, for versions 1.04beta through 2.0. Documents declaring 1.16 are validated against the 1.16.1 schema.

## CI/CD

GitHub Actions workflows in `.github/workflows/`:
- `deploy.yml`: Main build, test, Sonar scan, and snapshot publishing (triggers on `1.x` branch)
- `deploy.yml`: Main build, test, and snapshot publishing (temporarily triggered from the `upgrade-netex-2.0_for_1.x` branch until the merge into `1.x`)
- Release workflows: GitFlow-based release management
- Publishes to Maven Central via JReleaser

Expand Down
122 changes: 113 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,120 @@
# netex-java-model [![CircleCI](https://circleci.com/gh/entur/netex-java-model/tree/master.svg?style=svg)](https://circleci.com/gh/entur/netex-java-model/tree/master)
# netex-java-model (1.x)

Downloads the NeTEx-XML XSD files from https://github.com/entur/NeTEx and generates java model using jaxb.
[![Build and push](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml/badge.svg?branch=1.x)](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml)
[![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex-java-model)
[![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Forg%2Fentur%2Fnetex-java-model%2Fmaven-metadata.xml&label=Snapshot)](https://central.sonatype.com/repository/maven-snapshots)
[![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](https://joinup.ec.europa.eu/software/page/eupl)
[![Java 8+](https://img.shields.io/badge/Java-8%2B-orange)](https://adoptium.net/)

You need xmlstarlet installed.
Java model classes generated from [NeTEx](https://github.com/TransmodelEcosystem/NeTEx) (Network Timetable Exchange) XML Schema Definition (XSD) files using JAXB. Maintained by [Entur AS](https://www.entur.org).

```mvn clean install```
This is the **1.x line**, which targets Java 8 and Java EE 8 (`javax.xml.bind`). The `master` branch holds the Jakarta EE line of the library.

## Overview

## Maven central
This project is available in the central maven repository.
See https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.entur%22
This library downloads the NeTEx XSD files from the [NeTEx repository](https://github.com/TransmodelEcosystem/NeTEx) and compiles them into JAXB-annotated Java model classes at build time. The generated classes support full marshalling and unmarshalling of NeTEx XML documents, including schema validation against multiple NeTEx versions. The legacy schemas used only for validation (1.04beta - 1.16.1) are downloaded from the [Entur NeTEx fork](https://github.com/entur/NeTEx).

# Related project
- **NeTEx version**: 2.0 (model generation), with legacy validation support back to 1.04beta
- **JAXB**: Java XML Bind 2.3 (Java EE 8, `javax.xml.bind`)
- **Generated package**: `org.rutebanken.netex.model`
- **GML types package**: `net.opengis.gml._3`
- **SIRI types package**: `uk.org.siri.siri`

See https://github.com/entur/netex-protobuf for a conversion of NeTEx xsd files to protobuf descriptors.
## Usage

### Release (Maven Central)

```xml
<dependency>
<groupId>org.entur</groupId>
<artifactId>netex-java-model</artifactId>
<version>LATEST</version>
</dependency>
```

See [Maven Central](https://central.sonatype.com/artifact/org.entur/netex-java-model) for the latest released version.

### Snapshot

Snapshots are published to the Sonatype snapshot repository. Add the repository to your `pom.xml`:

```xml
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
```

Then add the dependency with the snapshot version:

```xml
<dependency>
<groupId>org.entur</groupId>
<artifactId>netex-java-model</artifactId>
<version>LATEST-SNAPSHOT</version>
</dependency>
```

## Building from Source

### Prerequisites

- Java 8+
- Maven 3.x
- [`xmlstarlet`](https://xmlstar.sourceforge.net/) (`apt install xmlstarlet` on Debian/Ubuntu, `brew install xmlstarlet` on macOS)

### Build

```bash
# Full build: downloads XSD files, generates JAXB classes, compiles, runs tests
mvn clean install

# Run tests only
mvn test

# Package without running tests
mvn package -DskipTests
```

The XSD files are downloaded from GitHub during the `generate-sources` phase and placed under `src/main/resources/xsd/`. The JAXB model is generated into `target/generated-sources/xjc/`.

## Project Structure

```
├── bin/
│ ├── netex-download-extract.sh # Downloads NeTEx XSD from GitHub
│ ├── annotation-replacer.sh # Post-processes generated Java files
│ ├── generate-dummy-bindings.py # Regenerates the bindings hiding the _Dummy suffix
│ └── version_updater.sh # Updates version references in bindings
├── bindings.xjb # JAXB customization bindings
├── src/main/java/org/rutebanken/
│ ├── netex/ # NeTEx utilities (validation, client, toString style)
│ └── util/ # XML adapters for Java time types
├── src/main/resources/xsd/ # Downloaded NeTEx XSD files (build artifact)
└── src/test/ # JUnit 5 marshalling/unmarshalling tests
```

## Key Technical Details

**JAXB customizations** (`bindings.xjb`):
- Java time type adapters: `LocalDateTime`, `LocalDate` and `LocalTime` via adapters in `org.rutebanken.util`, `Duration` via `jaxb-java-time-adapters`
- Fluent builder API (`withX()` methods) via `jaxb-fluent-api`
- Property name conflict resolution
- Package mapping to `org.rutebanken.netex.model`
- Hiding of the `_Dummy` suffix that NeTEx 2.0 puts on abstract substitution-group heads (`DayType_Dummy` is the head of `DayType`): containers expose `getDayType()` instead of `getDayType_Dummy()`, `ObjectFactory` exposes `createDayType_(...)` and the few classes generated for such heads keep a trailing underscore, as in `netex-java-model` 1.0.x. These bindings are generated by `bin/generate-dummy-bindings.py` and must be regenerated when the schema is upgraded.

**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.04beta through 2.0. A version is validated against its latest patch schema: documents declaring 1.16 are validated against the 1.16.1 schema, which is backward compatible with 1.16.

## License

Licensed under the [European Union Public Licence (EUPL) version 1.2](https://joinup.ec.europa.eu/software/page/eupl).

## Related Projects

- [netex-protobuf](https://github.com/entur/netex-protobuf) — NeTEx XSD files converted to protobuf descriptors
- [NeTEx (Entur fork)](https://github.com/entur/NeTEx) — legacy NeTEx XSD files used by this library for validation
Loading
Loading