public TransformFixtureXmlResult Validate() { using (XsltOutputStream) using (var xsltResultReader = CreateValidationAwareReader(XsltOutputStream)) { var navigator = new XPathDocument(xsltResultReader).CreateNavigator(); var xmlResult = new TransformFixtureXmlResult(navigator, navigator.GetNamespaceManager().AddNamespaces <TTransform>()); xmlResult.CheckValuedness(ValuednessValidationCallback); return(xmlResult); } }
private void ValidateSetup() { using (var stringReader = new StringReader(new TTransform().XmlContent)) using (var xmlReader = XmlReader.Create(stringReader, new XmlReaderSettings { XmlResolver = null })) { var navigator = new XPathDocument(xmlReader).CreateNavigator(); var output = navigator.SelectSingleNode("/xsl:stylesheet/xsl:output/@method", navigator.GetNamespaceManager().AddNamespaces <TTransform>()); if (output != null && !output.Value.Equals("xml", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException($"Transform produces a {output.Value} output and not an XML one."); } } switch (ContentProcessing) { case XmlSchemaContentProcessing.None: case XmlSchemaContentProcessing.Skip: break; case XmlSchemaContentProcessing.Lax: case XmlSchemaContentProcessing.Strict: if (!Schemas.Any()) { throw new InvalidOperationException("At least one XML Schema to which the output must conform to must be setup."); } break; } }
private void ValidateSetup() { using (var sr = new StringReader(new TTransform().XmlContent)) { var navigator = new XPathDocument(sr).CreateNavigator(); var output = navigator.SelectSingleNode("/xsl:stylesheet/xsl:output/@method", navigator.GetNamespaceManager().AddNamespaces <TTransform>()); if (output != null && output.Value.Equals("xml", StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Transform produces an XML output and not a text one."); } } }