I need to validate a small fragment of an xml file against a schema. Essentially, I’d like to ask the question “Does element X in XML document Y conform to its type as defined in schema Z?” and if not get a message describing why. This has to account for restrictions placed on those types as well (e.g. maxLength, minInclusive).
Is this possible?
It turns out this was much easier than I expected. The solution was to create a new schema that contains as its root the one element I want to verify. Once this schema is added to the schemaset, you can simply validate the fragment as you would any complete document.