<?php
/**
 * File Path: includes/api/class-mbs-onix-exporter-31.php
 *
 * ONIX 3.1 Exporter -- My Book Showroom
 *
 * Concrete exporter for ONIX 3.1 short-tag XML.
 * Extends MBS_Onix_Exporter_30.
 *
 * ONIX 3.1 backward compatibility: a valid ONIX 3.0 rev.08 file that avoids
 * deprecated elements is "3.1-ready" with only two changes:
 *   1. root release attribute:  "3.0"  -->  "3.1"
 *   2. xmlns namespace URL:     /3.0/  -->  /3.1/
 *
 * All product-level output is inherited from MBS_Onix_Exporter_30 unchanged,
 * because MBS_Onix_Exporter_30 already avoids all elements deprecated or
 * removed in ONIX 3.1 (the deprecated flat <audiencecode> was replaced by
 * the proper <audience><b204><b206> composite in Sprint B/F-001).
 *
 * Spec: ONIX-31-Implementation-Spec-2026-05-04.md
 *
 * @package    My_Book_Showroom
 * @subpackage Includes/Api
 * @since      1.6.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class MBS_Onix_Exporter_31 extends MBS_Onix_Exporter_30 { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- mbs_/MBS_ prefix is correct; scanner not configured with plugin prefix

	/**
	 * Override: open root element with ONIX 3.1 release attribute and namespace.
	 *
	 * @param XMLWriter $w
	 */
	protected function open_message( XMLWriter $w ): void {
		$w->startElement( 'ONIXmessage' );
		$w->writeAttribute( 'release', '3.1' );
		$w->writeAttribute( 'xmlns', 'http://ns.editeur.org/onix/3.1/short' );
	}
}
