Table of Contents

No Table of Contents available.

Validating IDML files with PHP

The IDML Validator for PHP is an open-source library, that allows validating IDML files natively in PHP.


This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/idml-validator.


The IDML Validator is mainly meant to be used by CLI. Nevertheless it can also be integrated in a PHP project.

Execute a validation via CLI

Run $ php vendor/bin/idml-validator validate /path/to/file.idml to validate your IDML file.

This will print something like:

Found 3 errors:
┌──────┬───────────────────────── designmap.xml ────────────────────────────────┐
│ Line │ Message                                                                │
│ 3    │ Element 'Document', attribute 'DOMVersion': [facet 'enumeration'] The  │
│      │ value '14.0' is not an element of the set {'8.0'}.                     │
│ 3    │ Element 'Document', attribute 'DOMVersion': '14.0' is not a valid valu │
│      │ e of the local atomic type.                                            │
│ 23   │ Element 'EndnoteOption': This element is not expected. Expected is one │
│      │ of ( TextVariable, { │
│      │ ng}Tags, Layer, {} │
│      │ MasterSpread, {}Sp │
│      │ read, Section, DocumentUser, CrossReferenceFormat, Index, {http://ns.a │
│      │}BackingStory ).              │


For an integrated use of the validator, take the Validation class, give it a file and a schema:


use IDML\Validator\File;
use IDML\Validator\Schema;
use IDML\Validator\Validation;

$validation = new Validation(
    new File('/path/to/file.idml'),
    new Schema()

$errors = $validation->getErrors();

One problem

A huge problem is that Adobe hasn't updated the schema since InDesign CS6. So every newer function will end in an error, even when it's official possible. We're talking to Adobe and waiting for an answer at the moment. So be careful about the errors and don't mind when you believe a function is possible but throws an error.