/** * @return The XML schema to be used for validating instances. May be * <code>null</code> if no XSDs are present. Also <code>null</code> if */ @Nullable protected final Schema getSchema () { if (m_bUseSchema) return m_aDocType.getSchema (); return null; }
/** * Validate the passed XML instance against the XML Schema of this document * type using the default class loader. * * @param aXML * The XML resource to be validated. May not be <code>null</code>. * @return A group of validation errors. Is empty if no error occurred. * <code>null</code> is returned if this document type has no XSDs * assigned and therefore not validation can take place. */ @Nullable default IErrorList validateXML (@Nonnull final IReadableResource aXML) { final Schema aSchema = getSchema (); return aSchema == null ? null : XMLSchemaValidationHelper.validate (aSchema, aXML); } }
/** * @param aLocale * The locale to use for error message creation. May be * <code>null</code> to use the system locale. * @return The compiled {@link Validator} object retrieved from the schema to * be obtained from {@link #getSchema()}. If this document type has no * XML Schema that no {@link Validator} can be created and the return * value is <code>null</code>. * @since 9.0.1 */ @Nullable default Validator getValidator (@Nullable final Locale aLocale) { final Schema aSchema = getSchema (); if (aSchema != null) { final Validator aValidator = aSchema.newValidator (); if (aValidator != null) { if (aLocale != null) EXMLParserProperty.GENERAL_LOCALE.applyTo (aValidator, aLocale); return aValidator; } } return null; }