public XmlReader CreateReader(ReaderOptions readerOptions) { var r = new XNodeReader(this); if ((readerOptions & ReaderOptions.OmitDuplicateNamespaces) != 0) { r.OmitDuplicateNamespaces = true; } return(r); }
public static void Validate (this XDocument source, XmlSchemaSet schemas, ValidationEventHandler validationEventHandler, bool addSchemaInfo) { if (source == null) throw new ArgumentNullException ("source"); if (schemas == null) throw new ArgumentNullException ("schemas"); var xrs = new XmlReaderSettings () { ValidationType = ValidationType.Schema }; xrs.Schemas = schemas; xrs.ValidationEventHandler += validationEventHandler; var xsource = new XNodeReader (source); var xr = XmlReader.Create (xsource, xrs); while (xr.Read ()) { if (addSchemaInfo) { if (xr.NodeType == XmlNodeType.Element) { xsource.CurrentNode.AddAnnotation (xr.SchemaInfo); while (xr.MoveToNextAttribute ()) if (xr.NamespaceURI != XUtil.XmlnsNamespace) xsource.GetCurrentAttribute ().AddAnnotation (xr.SchemaInfo); xr.MoveToElement (); } } } }
public XmlReader CreateReader (ReaderOptions readerOptions) { var r = new XNodeReader (this); if ((readerOptions & ReaderOptions.OmitDuplicateNamespaces) != 0) r.OmitDuplicateNamespaces = true; return r; }