Skip to content

Conversation

DaveRandom
Copy link
Contributor

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 http://stackoverflow.com/q/15948847/889949 for more information.

@hakre
Copy link
Contributor

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.

Added support for adding fixed/default values during XSD validation
and added/updated associated tests
@DaveRandom
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants