Solving No matching global declaration available for the validation root.

Had to create a custom XML for Pohoda accounting software, but hit some errors so I decided to make a PHPUnit test for validating it against its XML schema definition (XSD) with PHPs DOMDocument::schemaValidate

/** @test */
public function validateStockXml()
{
$this->pohoda->createStockXml();
$xml = new \DOMDocument();
$xml->load(Pohoda::STOCK_XML_PATH);

$isValid = $xml->schemaValidate('http://www.stormware.cz/schema/version_2/stock.xsd');
$this->assertTrue($isValid);
}

Stuck with the following error for a couple of hours 😦

Element ‘{http://www.stormware.cz/schema/version_2/data.xsd}dataPack’: No matching global declaration available for the validation root.

After a lot of trial and error decided to google more and more I finally found the solution at http://www.scriptscoop.me/t/81762e7e42e7/php-xml-validation-no-matching-global-declaration-available-for-the-valida.html

Changing the schema URL to http://www.stormware.cz/schema/version_2/data.xsd instead using http://www.stormware.cz/schema/version_2/stock.xsd solved the problem.

So easy, huh 🙂 Always learning.

Advertisements

Author: Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s