Skip to content

Add schema default/fixed value support in DOM #325

merged 1 commit into from Aug 11, 2013

3 participants


Added support for adding fixed/default values during XSD validation in the DOM extension.

This patch adds a second (optional) $flags argument to DOMDocument::schemaValidate() and DOMDocument::schemaValidateSource(), which is a bitmask of libxml schema validation context options. It also defines an additional PHP constant, LIBXML_SCHEMA_CREATE, corresponding to libxml's XML_SCHEMA_VAL_VC_I_CREATE, which is currently the only valid flag that can be passed. When passed, the schema validation procedure will add default values from the schema when they are unspecified in the document.

The default value for the optional $flags parameter is 0, which results in the current behaviour - hence merging this feature does not cause a BC-break.

See for more information.

hakre commented Apr 12, 2013

This is pretty nice. I hope I get the time at the weekend to compile PHP 5.5 and test this. I'd say you can squash the four commits into one to polish this a bit.

@DaveRandom DaveRandom Add schema default/fixed value support
Added support for adding fixed/default values during XSD validation
and added/updated associated tests

@hakre Squashed for your compiling pleasure. Also note that this should backport nicely to 5.4 and even 5.3 if you really want. The only stipulation is that you compile against libxml >=2.6.14.

@php-pulls php-pulls merged commit c091819 into php:PHP-5.5 Aug 11, 2013

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.