"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:u%23dCfx8EHHA.924@TK2MSFTNGP02.phx.gbl...
> Bardo wrote:
>
>> Does anyone know if it is possible, and if so how, to perform validation
>> of
>> a simple non XML string against certain XSD restrictions, without having
>> the
>> entire XML document to validate against the schema.
>> To elaborate -
>> - Within XSD certain restrictions are defined for a particular
>> element/attribute, such as datatype, minlength, maxlength, valid
>> enumeration
>> values etc.
>> Is it at all possible to validate a simple string value against these
>> restrictions defined within the schema.
>> I.e. I do not have the entire XML document that matches the schema. I do
>> not
>> even have any XML at all - I simply have a string value which represents
>> one
>> of the elements' values in the schema. I would like to utilise the power
>> of
>> XSD to validate the value, rather than writing my own code to check the
>> datatype, length, allowed values etc.
>
> With .NET 2.0 and later the XmlDocument has a method called Validate where
> you can pass in a single node to be validated. So you will at least to
> create e.g. an element node and pass that to the validate method.
>
> Then, also in .NET 2.0 and later, there is the XmlSchemaValidator class
> that has method likes ValidateAttribute, ValidateElement, ValidateText
> that allows you to validate certain components.
>
> --
>
> Martin Honnen --- MVP XML
>
http://JavaScript.FAQTs.com/