Skip to content

Add schema default/fixed value support in DOM #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2013
Merged

Add schema default/fixed value support in DOM #325

merged 1 commit into from
Aug 11, 2013

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