Fix undefined behavior validating XSD substitution groups

A bug in XSD substitution group validation would result in an invalid
cast of SchemaType::Ptr to XsdComplexType::Ptr, in which case evaluating
complexType->prohibitedSubstitutions() exhibited undefined behavior.  In
practice this caused validation against XSD schemas containing
substitution groups to fail on some machines, where ORing the checkSet
mask against out of bounds memory could cause the function

XsdSchemaHelper::substitutionGroupOkTransitive()

to return a false negative.

Minus the bug fix, the regression test added in this commit failed on
(at least) Linux ARM when compiled with the Linaro toolchain 2013.01 g++
4.7, with flags -marm -mcpu=cortex-a8 -O2.  However, it did not fail on
a Linux amd64 machine prior to the bug fix.

Change-Id: Idd060a941a3bc0620f1fcc903375e43022bdcbdc
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Merge branch 'stable' into dev

Change-Id: Icbade3b8a1098b442dccb04c85c597e9c7adc423