/// <summary> /// Accept a node and an atomic value and return the sequence containing the string /// value of the node followed by the value. /// </summary> public static XdmValue combine(XdmNode node, XdmAtomicValue value) { ArrayList list = new ArrayList(); list.Add(new XdmAtomicValue(node.StringValue)); list.Add(value); return new XdmValue(list); }
public XdmNodeNavigator(XdmNodeNavigator other) { if (other == null) throw new ArgumentNullException("other"); this.currentNode = other.currentNode; this.nameTable = other.nameTable; }
public void Message(XdmNode content, bool terminate, IXmlLocation location) { if (terminate) log.ErrorFormat("{0} ({1}, line {2})", content.StringValue, location.BaseUri, location.LineNumber); else log.Warn(content.StringValue); }
public XdmNodeNavigator(XdmNode node) { if (node == null) throw new ArgumentNullException("node"); this.currentNode = node; this.nameTable = CreateNameTable(); }
private XdmNode getLinkedDocument(XdmNode element, Processor processor, bool validate) { String href = element.GetAttributeValue(xlinkHref); DocumentBuilder builder = processor.NewDocumentBuilder(); Uri target = new Uri(element.BaseUri, href); builder.IsLineNumbering = true; if (validate) { builder.SchemaValidationMode = SchemaValidationMode.Strict; } return builder.Build(target); }
/// <summary> /// Construct a QName from a lexical QName, supplying an element node whose /// in-scope namespaces are to be used to resolve any prefix contained in the QName. /// </summary> /// <remarks> /// <para>This constructor checks that the components of the QName are /// lexically valid.</para> /// <para>If the lexical QName has no prefix, the name is considered to be in the /// default namespace, as defined by <c>xmlns="..."</c>.</para> /// <para>If the prefix of the lexical QName is not in scope, returns null.</para> /// </remarks> /// <param name="lexicalQName">The lexical QName, in the form <code>prefix:local</code> /// or simply <c>local</c>.</param> /// <param name="element">The element node whose in-scope namespaces are to be used /// to resolve the prefix part of the lexical QName.</param> /// <exception cref="ArgumentException">If the prefix of the lexical QName is not in scope</exception> /// <exception cref="ArgumentException">If the lexical QName is invalid /// (for example, if it contains invalid characters)</exception> /// public QName(String lexicalQName, XdmNode element) { try { NodeInfo node = (NodeInfo)element.value; NamePool pool = node.getConfiguration().getNamePool(); int nc = pool.allocateLexicalQName(lexicalQName, true, new InscopeNamespaceResolver(node), node.getConfiguration().getNameChecker()); this.uri = pool.getURI(nc); this.local = pool.getLocalName(nc); this.prefix = pool.getPrefix(nc); } catch (net.sf.saxon.trans.DynamicError err) { throw new ArgumentException(err.getMessage()); } }
/// <summary> /// Create an XdmValue from an underlying Saxon ValueRepresentation object. /// This method is provided for the benefit of applications that need to mix /// use of the Saxon .NET API with direct use of the underlying objects /// and methods offered by the Java implementation. /// </summary> /// <param name="value">An object representing an XDM value in the /// underlying Saxon implementation.</param> /// <returns>An XdmValue that wraps the underlying Saxon value /// representation.</returns> public static XdmValue Wrap(ValueRepresentation value) { XdmValue result; if (value == null || value is EmptySequence) { return XdmEmptySequence.INSTANCE; } else if (value is JAtomicValue) { result = new XdmAtomicValue(); } else if (value is NodeInfo) { result = new XdmNode(); } else { result = new XdmValue(); } result.value = value; return result; }
/// <summary> /// Compile a schema document, located at an <c>XdmNode</c>. This may be a document node whose /// child is an <c>xs:schema</c> element, or it may be /// the <c>xs:schema</c> element itself. The resulting schema components are added /// to the cache. /// </summary> /// <param name="node">The document node or the outermost element node of a schema document.</param> public void Compile(XdmNode node) { if (reporter == null) { reporter = new ErrorReporter(new List <XmlProcessingError>()); } try { config.readInlineSchema((JNodeInfo)node.value, null, reporter); } catch (JSchemaException e) { throw new StaticError(e); } }
/// <summary> /// Compile a schema document, located at an XdmNode. This may be a document node whose /// child is an <c>xs:schema</c> element, or it may be /// the <c>xs:schema</c> element itself. The resulting schema components are added /// to the cache. /// </summary> /// <param name="node">The document node or the outermost element node of a schema document.</param> public void Compile(XdmNode node) { ErrorGatherer eg = null; if (errorList != null) { eg = new ErrorGatherer(errorList); } try { config.readInlineSchema((NodeInfo)node.value, null, eg); } catch (SchemaException e) { throw new StaticError(e); } }
/// <summary> /// Execute an updating query. /// </summary> /// <returns>An array containing the root nodes of documents that have been /// updated by the query.</returns> /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure /// occurs while evaluating the expression, or if the expression is not an /// updating query.</exception> public XdmNode[] RunUpdate() { if (!exp.isUpdateQuery()) { throw new DynamicError("Not an updating query"); } try { java.util.Set updatedDocs = exp.runUpdate(context); XdmNode[] result = new XdmNode[updatedDocs.size()]; int i = 0; for (java.util.Iterator iter = updatedDocs.iterator(); iter.hasNext();) { result[i++] = (XdmNode)XdmValue.Wrap((NodeInfo)iter.next()); } return(result); } catch (JXPathException err) { throw new DynamicError(err); } }
/// <summary> /// Create an XdmValue from an underlying Saxon ValueRepresentation object. /// This method is provided for the benefit of applications that need to mix /// use of the Saxon .NET API with direct use of the underlying objects /// and methods offered by the Java implementation. /// </summary> /// <param name="value">An object representing an XDM value in the /// underlying Saxon implementation.</param> /// <returns>An XdmValue that wraps the underlying Saxon value /// representation.</returns> public static XdmValue Wrap(ValueRepresentation value) { XdmValue result; if (value == null || value is EmptySequence) { return(XdmEmptySequence.INSTANCE); } else if (value is JAtomicValue) { result = new XdmAtomicValue(); } else if (value is NodeInfo) { result = new XdmNode(); } else { result = new XdmValue(); } result.value = value; return(result); }
private IList getCollection(XdmNode collectionNode, string href) { ArrayList list = new ArrayList(10); IEnumerator e = collectionNode.EnumerateAxis( XdmAxis.Child, new QName("input-document")); while (e.MoveNext()) { XdmNode node = (XdmNode)e.Current; list.Add(new Uri(href)); } return list; }
public void setTestCase(XdmNode testCase) { this.testCase = testCase; }
private bool testAssertion2(XdmNode assertion, Outcome outcome, XPathCompiler assertXpc, XPathCompiler catalogXpc, bool debug) { string tag = assertion.NodeName.LocalName; if (tag.Equals("assert-eq")) { if (outcome.isException()) { return false; } else { XPathSelector s = assertXpc.Compile("$result eq " + assertion.StringValue).Load(); s.SetVariable(new QName("result"), outcome.getResult()); XdmAtomicValue item = (XdmAtomicValue)s.EvaluateSingle(); if (s == null) { return false; } return (bool)item.Value; } } if (tag.Equals("assert-deep-eq")) { if (outcome.isException()) { return false; } else { XPathSelector s = assertXpc.Compile("deep-equal($result , (" + assertion.StringValue + "))").Load(); s.SetVariable(new QName("result"), outcome.getResult()); return (bool)((XdmAtomicValue)s.Evaluate()).Value; } } else if (tag.Equals("assert-permutation")) { // TODO: extend this to handle nodes (if required) if (outcome.isException()) { return false; } else { try { int expectedItems = 0; Hashtable expected = new Hashtable(); XPathSelector s = assertXpc.Compile("(" + assertion.StringValue + ")").Load(); s.SetVariable(new QName("result"), outcome.getResult()); // not used, but we declared it net.sf.saxon.lib.StringCollator collator = net.sf.saxon.expr.sort.CodepointCollator.getInstance(); net.sf.saxon.expr.XPathContext context = new net.sf.saxon.expr.XPathContextMajor(net.sf.saxon.value.StringValue.EMPTY_STRING, assertXpc.Processor.Implementation); /* foreach (XdmItem item in s) { expectedItems++; XdmValue value = (XdmValue) item; Object comparable = value.isNaN() ? AtomicSortComparer.COLLATION_KEY_NaN : value.getXPathComparable(false, collator, context); expected.add(comparable); } */ int actualItems = 0; /*foreach (XdmItem item in outcome.getResult()) { actualItems++; AtomicValue value = (AtomicValue) item.getUnderlyingValue(); Object comparable = value.isNaN() ? AtomicSortComparer.COLLATION_KEY_NaN : value.getXPathComparable(false, collator, context); if (!expected.Contains(comparable)) { return false; } }*/ return actualItems == expectedItems; } catch (DynamicError e) { return false; } } } else if (tag.Equals("assert-serialization")) { if (outcome.isException()) { return false; } else { string normalizeAtt = assertion.GetAttributeValue(new QName("normalize-space")); bool normalize = normalizeAtt != null && ("true".Equals(normalizeAtt.Trim()) || "1".Equals(normalizeAtt.Trim())); string ignoreAtt = assertion.GetAttributeValue(new QName("ignore-prefixes")); bool ignorePrefixes = ignoreAtt != null && ("true".Equals(ignoreAtt.Trim()) || "1".Equals(ignoreAtt.Trim())); catalogXpc.BaseUri = ""; string comparand = catalogXpc.Evaluate("if (@file) then unparsed-text(resolve-uri(@file, base-uri(.))) else string(.)", assertion).ToString(); if (normalize) { comparand = net.sf.saxon.value.Whitespace.collapseWhitespace(comparand).ToString(); } StringWriter tw = new StringWriter(); Serializer serializer = new Serializer(); serializer.SetOutputWriter(tw); serializer.SetOutputProperty(Serializer.METHOD, "xml"); serializer.SetOutputProperty(Serializer.INDENT, "no"); serializer.SetOutputProperty(Serializer.OMIT_XML_DECLARATION, "yes"); assertXpc.Processor.WriteXdmValue(outcome.getResult(), serializer); if (comparand.Equals(tw.ToString())) { return true; } DocumentBuilder builder = assertXpc.Processor.NewDocumentBuilder(); StringReader reader = new StringReader("<z>" + comparand + "</z>"); builder.BaseUri = assertion.BaseUri; XdmNode expected = builder.Build(reader); int flag = 0; flag |= net.sf.saxon.functions.DeepEqual.INCLUDE_COMMENTS; flag |= net.sf.saxon.functions.DeepEqual.INCLUDE_PROCESSING_INSTRUCTIONS; if (!ignorePrefixes) { flag |= net.sf.saxon.functions.DeepEqual.INCLUDE_NAMESPACES; flag |= net.sf.saxon.functions.DeepEqual.INCLUDE_PREFIXES; } flag |= net.sf.saxon.functions.DeepEqual.COMPARE_STRING_VALUES; flag |= net.sf.saxon.functions.DeepEqual.WARNING_IF_FALSE; try { net.sf.saxon.om.SequenceIterator iter0; XdmValue v = outcome.getResult(); if (v.Count == 1 && v is XdmNode && ((XdmNode)v).NodeKind == XmlNodeType.Document) { iter0 = ((XdmNode)v).Implementation.iterateAxis(net.sf.saxon.om.Axis.CHILD); } else { iter0 = net.sf.saxon.value.Value.asIterator(outcome.getResult().Unwrap()); } net.sf.saxon.om.SequenceIterator iter1 = (expected.Implementation.iterateAxis(net.sf.saxon.om.Axis.CHILD).next()).iterateAxis(net.sf.saxon.om.Axis.CHILD); return net.sf.saxon.functions.DeepEqual.deepEquals( iter0, iter1, new net.sf.saxon.expr.sort.GenericAtomicComparer(net.sf.saxon.expr.sort.CodepointCollator.getInstance(), null), assertXpc.Processor.Implementation, flag); } catch (DynamicError e) { // e.printStackTrace(); return false; } } } else if (tag.Equals("assert-serialization-error")) { if (outcome.isException()) { return false; } else { string expectedError = assertion.GetAttributeValue(new QName("code")); StringWriter sw = new StringWriter(); Serializer serializer = new Serializer(); serializer.SetOutputWriter(sw); serializer.SetOutputProperty(Serializer.METHOD, "xml"); serializer.SetOutputProperty(Serializer.INDENT, "no"); serializer.SetOutputProperty(Serializer.OMIT_XML_DECLARATION, "yes"); try { assertXpc.Processor.WriteXdmValue(outcome.getResult(), serializer); return false; } catch (DynamicError err) { bool b = expectedError.Equals(err.ErrorCode.LocalName); if (!b) { feedback.Message("Expected " + expectedError + ", got " + err.ErrorCode.LocalName, false); } return true; } } } else if (tag.Equals("assert-empty")) { if (outcome.isException()) { return false; } else { XdmValue result = outcome.getResult(); return result.Count == 0; } } else if (tag.Equals("assert-count")) { if (outcome.isException()) { return false; } else { XdmValue result = outcome.getResult(); return result.Count == int.Parse(assertion.StringValue); } } else if (tag.Equals("assert")) { if (outcome.isException()) { return false; } else { XPathSelector s = assertXpc.Compile(assertion.StringValue).Load(); s.SetVariable(new QName("result"), outcome.getResult()); return (bool)((XdmAtomicValue)s.EvaluateSingle()).Value; } } else if (tag.Equals("assert-string-value")) { if (outcome.isException()) { return false; } else { XdmValue resultValue = outcome.getResult(); string resultstring; string assertionstring = assertion.StringValue; if (resultValue is XdmNode) { resultstring = ((XdmNode)resultValue).StringValue; }else if(resultValue is XdmAtomicValue){ resultstring = ((XdmAtomicValue)resultValue).ToString(); } else { bool first = true; StringBuilder fsb = new StringBuilder(256); foreach (XdmItem item in resultValue) { if (first) { first = false; } else { fsb.Append(' '); } fsb.Append(item.Unwrap().getStringValue()); } resultstring = fsb.ToString(); } string normalizeAtt = assertion.GetAttributeValue(new QName("normalize-space")); if (normalizeAtt != null && (normalizeAtt.Trim().Equals("true") || normalizeAtt.Trim().Equals("1"))) { assertionstring = net.sf.saxon.value.Whitespace.collapseWhitespace(assertionstring).ToString(); resultstring = net.sf.saxon.value.Whitespace.collapseWhitespace(resultstring).ToString(); } if (resultstring.Equals(assertionstring)) { return true; } else { if (debug) { if (resultstring.Length != assertionstring.Length) { Console.WriteLine("Result length " + resultstring.Length + "; expected length " + assertionstring.Length); } int len = Math.Min(resultstring.Length, assertionstring.Length); for (int i = 0; i < len; i++) { if (resultstring[i] != assertionstring[i]) { feedback.Message("Results differ at index " + i + "(\"" + resultstring.Substring(i, (i + 10 > len ? len : i + 10)) + "\") vs (\"" + assertionstring.Substring(i, (i + 10 > len ? len : i + 10)) + "\")", false); break; } } } return false; } } } else if (tag.Equals("assert-type")) { if (outcome.isException()) { return false; } else { XPathSelector s = assertXpc.Compile("$result instance of " + assertion.StringValue).Load(); s.SetVariable(new QName("result"), outcome.getResult()); return (bool)((XdmAtomicValue)s.EvaluateSingle()).Value; } } else if (tag.Equals("assert-true")) { if (outcome.isException()) { return false; } else { XdmValue result = outcome.getResult(); return result.Count == 1 && ((XdmItem)result).IsAtomic() && ((XdmAtomicValue)result).GetPrimitiveTypeName().Equals(QName.XS_BOOLEAN) && (((XdmAtomicValue)result).GetBooleanValue()); } } else if (tag.Equals("assert-false")) { if (outcome.isException()) { return false; } else { XdmValue result = outcome.getResult(); return result.Count == 1 && ((XdmItem)result.Simplify).IsAtomic() && ((XdmAtomicValue)result.Simplify).GetPrimitiveTypeName().Equals(QName.XS_BOOLEAN) && !(bool)((XdmAtomicValue)result.Simplify).Value; } } else if (tag.Equals("error")) { string expectedError = assertion.GetAttributeValue(new QName("code")); //noinspection ThrowableResultOfMethodCallIgnored Exception err = outcome.getException(); QName errorCode = null; if (err is DynamicError) { errorCode = ((DynamicError)outcome.getException()).ErrorCode; } else { errorCode = ((StaticError)outcome.getException()).ErrorCode; } return outcome.isException() && (expectedError.Equals("*") || (errorCode != null && errorCode.LocalName.Equals(expectedError)) || (outcome.hasReportedError(expectedError))); } else if (tag.Equals("all-of")) { XdmValue children = catalogXpc.Evaluate("*", assertion); foreach (XdmItem child in children) { if (!testAssertion((XdmNode)child, outcome, assertXpc, catalogXpc, debug)) { return false; } } return true; } else if (tag.Equals("any-of")) { XdmValue children = catalogXpc.Evaluate("*", assertion); foreach (XdmItem child in children) { if (testAssertion((XdmNode)child, outcome, assertXpc, catalogXpc, debug)) { return true; } } return false; } throw new Exception("Unknown assertion element " + tag); }
/// <summary> /// Get the item type representing the node kind of a supplied node /// </summary> /// <param name="node">The node whose node kind is required</param> /// <returns>The relevant node kind</returns> public static XdmNodeKind ForNode(XdmNode node) { return(ForNodeType(node.NodeKind)); }
public XqtsModuleResolver(XdmNode testCase, XPathExecutable findModule) { this.testCase = testCase; this.findModule = findModule; }
/// <summary> /// Constructor to create an Xml resource using a specific node /// </summary> /// <param name="doc">the node in question (usually but not necessarily a document node)</param> public XmlResource(XdmNode doc) { resource = new net.sf.saxon.resource.XmlResource(doc.Implementation); }
bool MoveToNextInCurrentSequence() { if (this.currentSequence.MoveNext()) { this.currentNode = (XdmNode)this.currentSequence.Current; return true; } return false; }
/// <summary>Locate and compile a stylesheet identified by an <?xml-stylesheet?> /// processing instruction within a source document. /// </summary> /// <param name="source">The document node of the source document containing the /// xml-stylesheet processing instruction.</param> /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object.</returns> /// <remarks>There are some limitations in the current implementation. The media type /// is ignored, as are the other parameters of the xml-stylesheet instruction. The /// href attribute must either reference an embedded stylesheet within the same /// document or a non-embedded external stylesheet.</remarks> public XsltExecutable CompileAssociatedStylesheet(XdmNode source) { // TODO: lift the restrictions if (source == null || source.NodeKind != XmlNodeType.Document) { throw new ArgumentException("Source must be a document node"); } IEnumerator kids = source.EnumerateAxis(XdmAxis.Child); QName xmlstyle = new QName("", "xml-stylesheet"); while (kids.MoveNext()) { XdmNode n = (XdmNode)kids.Current; if (n.NodeKind == XmlNodeType.ProcessingInstruction && n.NodeName.Equals(xmlstyle)) { // TODO: check the media type String href = JProcInstParser.getPseudoAttribute(n.StringValue, "href"); if (href == null) { throw new DynamicError("xml-stylesheet processing instruction has no href attribute"); } String fragment = null; int hash = href.LastIndexOf('#'); if (hash == 0) { if (href.Length == 1) { throw new DynamicError("Relative URI of '#' is invalid"); } fragment = href.Substring(1); JNodeInfo target = ((JDocumentInfo)source.value).selectID(fragment, true); XdmNode targetWrapper = null; if (target == null) { // There's a problem here because the Microsoft XML parser doesn't // report id values, so selectID() will never work. We work around that // by looking for an attribute named "id" appearing on an xsl:stylesheet // or xsl:transform element QName qid = new QName("", "id"); IEnumerator en = source.EnumerateAxis(XdmAxis.Descendant); while (en.MoveNext()) { XdmNode x = (XdmNode)en.Current; if (x.NodeKind == XmlNodeType.Element && x.NodeName.Uri == "http://www.w3.org/1999/XSL/Transform" && (x.NodeName.LocalName == "stylesheet" || x.NodeName.LocalName == "transform" && x.GetAttributeValue(qid) == fragment)) { targetWrapper = x; } } } else { targetWrapper = (XdmNode)XdmValue.Wrap(target); } if (targetWrapper == null) { throw new DynamicError("No element with id='" + fragment + "' found"); } return Compile(targetWrapper); } else if (hash > 0) { throw new NotImplementedException("href cannot identify an embedded stylesheet in a different document"); } else { Uri uri = new Uri(n.BaseUri, href); return Compile(uri); } } } throw new DynamicError("xml-stylesheet processing instruction not found"); }
static bool NamespaceScopeOk(XdmNode nsNode, XPathNamespaceScope namespaceScope) { switch (namespaceScope) { case XPathNamespaceScope.All: return true; case XPathNamespaceScope.ExcludeXml: return nsNode.NodeName == null || nsNode.NodeName.LocalName != "xml"; case XPathNamespaceScope.Local: if (nsNode.NodeName != null && nsNode.NodeName.LocalName == "xml") { return false; } XdmNode parentNode = nsNode.Parent.Parent; if (parentNode != null) { IEnumerator parentScope = parentNode.EnumerateAxis(XdmAxis.Namespace); while (parentScope.MoveNext()) { XdmNode pNsNode = (XdmNode)parentScope.Current; if (nsNode.NodeName == pNsNode.NodeName && nsNode.StringValue == pNsNode.StringValue) { return false; } } } return true; default: throw new ArgumentOutOfRangeException("namespaceScope"); } }
bool MoveTo(XdmAxis axis) { IEnumerator en = this.currentNode.EnumerateAxis(axis); if (en.MoveNext()) { this.currentNode = (XdmNode)en.Current; switch (axis) { case XdmAxis.Attribute: case XdmAxis.Child: case XdmAxis.Namespace: this.currentSequence = en; break; default: this.currentSequence = null; break; } return true; } return false; }
/// <summary> /// Add an instance document to the list of documents to be validated. /// </summary> /// <param name="source">supplied as a XdmNode value</param> public void AddSource(XdmNode source) { sources.Add((JNodeInfo)source.value); }
public override bool MoveToNextNamespace(XPathNamespaceScope namespaceScope) { if (this.NodeType != XPathNodeType.Namespace) { return false; } while (this.currentSequence.MoveNext()) { XdmNode node = (XdmNode)this.currentSequence.Current; if (!NamespaceScopeOk(node, namespaceScope)) { continue; } this.currentNode = node; return true; } return false; }
public override bool MoveToFirstNamespace(XPathNamespaceScope namespaceScope) { if (this.NodeType != XPathNodeType.Element) { return false; } IEnumerator en = this.currentNode.EnumerateAxis(XdmAxis.Namespace); while (en.MoveNext()) { XdmNode node = (XdmNode)en.Current; if (!NamespaceScopeOk(node, namespaceScope)) { continue; } this.currentNode = node; this.currentSequence = en; return true; } return false; }
/** * Run a test case * * @param testCase the test case element in the catalog * @param xpc the XPath compiler to be used for compiling XPath expressions against the catalog * @throws SaxonApiException */ private void runTestCase(XdmNode testCase, XPathCompiler xpc) { string testCaseName = testCase.GetAttributeValue(new QName("name")); feedback.Message("Test case " + testCaseName + Environment.NewLine, false); XdmNode exceptionElement = null; try { exceptionElement = exceptionsMap[testCaseName]; } catch (Exception) { } XdmNode alternativeResult = null; XdmNode optimization = null; if (exceptionElement != null) { string runAtt = exceptionElement.GetAttributeValue(new QName("run")); if ("no".Equals(runAtt)) { WriteTestCaseElement(testCaseName, "notRun", "see exceptions file"); return; } if (unfolded && "not-unfolded".Equals(runAtt)) { WriteTestCaseElement(testCaseName, "notRun", "see exceptions file"); return; } alternativeResult = (XdmNode)xpc.EvaluateSingle("result", exceptionElement); optimization = (XdmNode)xpc.EvaluateSingle("optimization", exceptionElement); } XdmNode environmentNode = (XdmNode)xpc.EvaluateSingle("environment", testCase); TestEnvironment env = null; if (environmentNode == null) { env = localEnvironments["default"]; } else { string envName = environmentNode.GetAttributeValue(new QName("ref")); if (envName == null) { env = processEnvironment(xpc, environmentNode, null); } else { try { env = localEnvironments[envName]; } catch (Exception) { } if (env == null) { try { env = globalEnvironments[envName]; } catch (Exception) { } } if (env == null) { Console.WriteLine("*** Unknown environment " + envName); WriteTestCaseElement(testCaseName, "fail", "Environment " + envName + " not found"); failures++; return; } } } env.xpathCompiler.BackwardsCompatible = false; env.processor.XmlVersion = (decimal)1.0; bool run = true; bool xpDependency = false; string hostLang; string langVersion; if (preferQuery) { hostLang = "XQ"; langVersion = "1.0"; } else { hostLang = "XP"; langVersion = "2.0"; } XdmValue dependencies = xpc.Evaluate("/*/dependency, ./dependency", testCase); foreach (XdmItem dependency in dependencies) { string type = ((XdmNode)dependency).GetAttributeValue(new QName("type")); if (type == null) { throw new Exception("dependency/@type is missing"); } string value = ((XdmNode)dependency).GetAttributeValue(new QName("value")); if (value == null) { throw new Exception("dependency/@value is missing"); } if (type.Equals("spec")) { if (value.Contains("XP") && !value.Contains("XQ")) { hostLang = "XP"; langVersion = (value.Equals("XP20") ? "2.0" : "3.0"); xpDependency = true; } else if (value.Contains("XP") && value.Contains("XQ") && preferQuery) { hostLang = "XQ"; langVersion = (value.Contains("XQ10+") || value.Contains("XQ30") ? "3.0" : "1.0"); } else if (value.Contains("XT")) { hostLang = "XT"; langVersion = (value.Contains("XT30+") || value.Contains("XT30") ? "3.0" : "1.0"); } else { hostLang = "XQ"; langVersion = (value.Contains("XQ10+") || value.Contains("XQ30") ? "3.0" : "1.0"); } } if (type.Equals("feature") && value.Equals("xpath-1.0-compatibility")) { hostLang = "XP"; langVersion = "3.0"; xpDependency = true; } if (type.Equals("feature") && value.Equals("namespace-axis")) { hostLang = "XP"; langVersion = "3.0"; xpDependency = true; } if (!DependencyIsSatisfied((XdmNode)dependency, env)) { Console.WriteLine("*** Dependency not satisfied: " + ((XdmNode)dependency).GetAttributeValue(new QName("type"))); WriteTestCaseElement(testCaseName, "notRun", "Dependency not satisfied"); run = false; } } if ((unfolded && !xpDependency) || optimization != null) { hostLang = "XQ"; if (langVersion.Equals("2.0")) { langVersion = "1.0"; } } if (run) { Outcome outcome = null; string exp = null; try { exp = xpc.Evaluate("if (test/@file) then unparsed-text(resolve-uri(test/@file, base-uri(.))) else string(test)", testCase).ToString(); } catch (DynamicError err) { Console.WriteLine("*** Failed to read query: " + err.Message); outcome = new Outcome(err); } if (outcome == null) { if (hostLang.Equals(("XP"))) { XPathCompiler testXpc = env.xpathCompiler; testXpc.XPathLanguageVersion = langVersion; testXpc.DeclareNamespace("fn", JNamespaceConstant.FN); testXpc.DeclareNamespace("xs", JNamespaceConstant.SCHEMA); testXpc.DeclareNamespace("math", JNamespaceConstant.MATH); testXpc.DeclareNamespace("map", JNamespaceConstant.MAP_FUNCTIONS); try { XPathSelector selector = testXpc.Compile(exp).Load(); foreach (QName varName in env.params1.Keys) { selector.SetVariable(varName, env.params1[varName]); } if (env.contextNode != null) { selector.ContextItem = env.contextNode; } selector.InputXmlResolver = new TestUriResolver(env); XdmValue result = selector.Evaluate(); outcome = new Outcome(result); } catch (DynamicError err) { Console.WriteLine(err.Message); outcome = new Outcome(err); } catch (StaticError err) { Console.WriteLine(err.Message); outcome = new Outcome(err); } catch (Exception err) { Console.WriteLine("*** Failed to read query: " + err.Message); outcome = new Outcome(new DynamicError("*** Failed to read query: " + err.Message)); } } else { XQueryCompiler testXqc = env.xqueryCompiler; testXqc.XQueryLanguageVersion = langVersion; testXqc.DeclareNamespace("fn", JNamespaceConstant.FN); testXqc.DeclareNamespace("xs", JNamespaceConstant.SCHEMA); testXqc.DeclareNamespace("math", JNamespaceConstant.MATH); testXqc.DeclareNamespace("map", JNamespaceConstant.MAP_FUNCTIONS); ErrorCollector errorCollector = new ErrorCollector(); //testXqc.setErrorListener(errorCollector); string decVars = env.paramDecimalDeclarations.ToString(); if (decVars.Length != 0) { int x = (exp.IndexOf("(:%DECL%:)")); if (x < 0) { exp = decVars + exp; } else { exp = exp.Substring(0, x) + decVars + exp.Substring(x + 13); } } string vars = env.paramDeclarations.ToString(); if (vars.Length != 0) { int x = (exp.IndexOf("(:%VARDECL%:)")); if (x < 0) { exp = vars + exp; } else { exp = exp.Substring(0, x) + vars + exp.Substring(x + 13); } } ModuleResolver mr = new ModuleResolver(xpc); mr.setTestCase(testCase); testXqc.QueryResolver = (IQueryResolver)mr; try { XQueryExecutable q = testXqc.Compile(exp); if (optimization != null) { /* XdmDestination expDest = new XdmDestination(); net.sf.saxon.Configuration config = driverProc.Implementation; net.sf.saxon.trace.ExpressionPresenter presenter = new net.sf.saxon.trace.ExpressionPresenter(driverProc.Implementation, expDest.getReceiver(config)); //q.getUnderlyingCompiledQuery().explain(presenter); presenter.close(); XdmNode explanation = expDest.XdmNode; XdmItem optResult = xpc.EvaluateSingle(optimization.GetAttributeValue(new QName("assert")), explanation); if ((bool)((XdmAtomicValue)optResult).Value) { Console.WriteLine("Optimization result OK"); } else { Console.WriteLine("Failed optimization test"); Serializer serializer = new Serializer(); serializer.SetOutputWriter(Console.Error); driverProc.WriteXdmValue(explanation, serializer); WriteTestCaseElement(testCaseName, "fail", "Failed optimization assertions"); failures++; return; }*/ } XQueryEvaluator selector = q.Load(); foreach (QName varName in env.params1.Keys) { selector.SetExternalVariable(varName, env.params1[varName]); } if (env.contextNode != null) { selector.ContextItem = env.contextNode; } selector.InputXmlResolver= new TestUriResolver(env); XdmValue result = selector.Evaluate(); outcome = new Outcome(result); } catch (DynamicError err) { Console.WriteLine("TestSet" + testFuncSet); Console.WriteLine(err.Message); outcome = new Outcome(err); outcome.setErrorsReported(errorCollector.getErrorCodes()); } catch(StaticError err){ Console.WriteLine("TestSet" + testFuncSet); Console.WriteLine(err.Message); outcome = new Outcome(err); outcome.setErrorsReported(errorCollector.getErrorCodes()); } catch(Exception err){ Console.WriteLine("TestSet" + testFuncSet); Console.WriteLine(err.Message); outcome = new Outcome(new DynamicError(err.Message)); outcome.setErrorsReported(errorCollector.getErrorCodes()); } } } XdmNode assertion; if (alternativeResult != null) { assertion = (XdmNode)xpc.EvaluateSingle("*[1]", alternativeResult); } else { assertion = (XdmNode)xpc.EvaluateSingle("result/*[1]", testCase); } if (assertion == null) { Console.WriteLine("*** No assertions found for test case " + testCaseName); WriteTestCaseElement(testCaseName, "fail", "No assertions in test case"); failures++; return; } XPathCompiler assertXpc = env.processor.NewXPathCompiler(); assertXpc.XPathLanguageVersion = "3.0"; assertXpc.DeclareNamespace("fn", JNamespaceConstant.FN); assertXpc.DeclareNamespace("xs", JNamespaceConstant.SCHEMA); assertXpc.DeclareNamespace("math", JNamespaceConstant.MATH); assertXpc.DeclareNamespace("map", JNamespaceConstant.MAP_FUNCTIONS); assertXpc.DeclareVariable(new QName("result")); bool b = testAssertion(assertion, outcome, assertXpc, xpc, debug); if (b) { Console.WriteLine("OK"); successes++; feedback.Message("OK" + Environment.NewLine, false); WriteTestCaseElement(testCaseName, "full", null); } else { if (outcome.isException()) { XdmItem expectedError = xpc.EvaluateSingle("result//error/@code", testCase); if (expectedError == null) { // if (debug) { // outcome.getException().printStackTrace(System.out); // } if (outcome.getException() is StaticError) { WriteTestCaseElement(testCaseName, "fail", "Expected success, got " + ((StaticError)outcome.getException()).ErrorCode); feedback.Message("*** fail, result " + ((StaticError)outcome.getException()).ErrorCode.LocalName + " Expected success." + Environment.NewLine, false); } else { WriteTestCaseElement(testCaseName, "fail", "Expected success, got " + ((DynamicError)outcome.getException()).ErrorCode); feedback.Message("*** fail, result " + ((DynamicError)outcome.getException()).ErrorCode.LocalName + " Expected success." + Environment.NewLine, false); } failures++; } else { if (outcome.getException() is StaticError) { WriteTestCaseElement(testCaseName, "different-error", "Expected error:" + expectedError.ToString() /*.GetstringValue()*/ + ", got " + ((StaticError)outcome.getException()).ErrorCode.ToString()); feedback.Message("*** fail, result " + ((StaticError)outcome.getException()).ErrorCode.LocalName + " Expected error:" + expectedError.ToString() + Environment.NewLine, false); } else { WriteTestCaseElement(testCaseName, "different-error", "Expected error:" + expectedError.ToString() /*.GetstringValue()*/ + ", got " + ((DynamicError)outcome.getException()).ErrorCode.ToString()); feedback.Message("*** fail, result " + ((DynamicError)outcome.getException()).ErrorCode.LocalName + " Expected error:" + expectedError.ToString() + Environment.NewLine, false); } wrongErrorResults++; } } else { try { WriteTestCaseElement(testCaseName, "fail", "Wrong results, got " + truncate(outcome.serialize(assertXpc.Processor))); }catch (Exception) { WriteTestCaseElement(testCaseName, "fail", "Wrong results, got "); } failures++; if (debug) { try { feedback.Message("Result:" + Environment.NewLine, false); // driverProc.WriteXdmValue(outcome.getResult(), driverSerializer); feedback.Message("=======" + Environment.NewLine, false); } catch (Exception) { } feedback.Message(outcome.getResult() + Environment.NewLine, false); } else { feedback.Message("*** fail (use -debug to show actual result)" + Environment.NewLine, false); } } } feedback.Feedback(successes, failures, 25693); } }
/// <summary> /// Compile a stylesheet, located at an XdmNode. This may be a document node whose /// child is an <c>xsl:stylesheet</c> or <c>xsl:transform</c> element, or it may be /// the <c>xsl:stylesheet</c> or <c>xsl:transform</c> element itself. /// </summary> /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object. /// The XsltExecutable may be run as many times as required, in the same or a different /// thread. The <c>XsltExecutable</c> is not affected by any changes made to the <c>XsltCompiler</c> /// once it has been compiled.</returns> public XsltExecutable Compile(XdmNode node) { PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates((JNodeInfo)node.value, info); return(new XsltExecutable(pss)); }
public override bool MoveTo(XPathNavigator other) { XdmNodeNavigator navigator = other as XdmNodeNavigator; if ((navigator != null) && navigator.currentNode.Root.Equals(this.currentNode.Root)) { this.currentNode = navigator.currentNode; this.currentSequence = null; return true; } return false; }
/// <summary>Locate and compile a stylesheet identified by an <?xml-stylesheet?> /// processing instruction within a source document. /// </summary> /// <param name="source">The document node of the source document containing the /// xml-stylesheet processing instruction.</param> /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object.</returns> /// <remarks>There are some limitations in the current implementation. The media type /// is ignored, as are the other parameters of the xml-stylesheet instruction. The /// href attribute must either reference an embedded stylesheet within the same /// document or a non-embedded external stylesheet.</remarks> public XsltExecutable CompileAssociatedStylesheet(XdmNode source) { // TODO: lift the restrictions if (source == null || source.NodeKind != XmlNodeType.Document) { throw new ArgumentException("Source must be a document node"); } IEnumerator kids = source.EnumerateAxis(XdmAxis.Child); QName xmlstyle = new QName("", "xml-stylesheet"); while (kids.MoveNext()) { XdmNode n = (XdmNode)kids.Current; if (n.NodeKind == XmlNodeType.ProcessingInstruction && n.NodeName.Equals(xmlstyle)) { // TODO: check the media type String href = JProcInstParser.getPseudoAttribute(n.StringValue, "href"); if (href == null) { throw new DynamicError("xml-stylesheet processing instruction has no href attribute"); } String fragment = null; int hash = href.LastIndexOf('#'); if (hash == 0) { if (href.Length == 1) { throw new DynamicError("Relative URI of '#' is invalid"); } fragment = href.Substring(1); JNodeInfo target = ((JDocumentInfo)source.value).selectID(fragment); XdmNode targetWrapper = null; if (target == null) { // There's a problem here because the Microsoft XML parser doesn't // report id values, so selectID() will never work. We work around that // by looking for an attribute named "id" appearing on an xsl:stylesheet // or xsl:transform element QName qid = new QName("", "id"); IEnumerator en = source.EnumerateAxis(XdmAxis.Descendant); while (en.MoveNext()) { XdmNode x = (XdmNode)en.Current; if (x.NodeKind == XmlNodeType.Element && x.NodeName.Uri == "http://www.w3.org/1999/XSL/Transform" && (x.NodeName.LocalName == "stylesheet" || x.NodeName.LocalName == "transform" && x.GetAttributeValue(qid) == fragment)) { targetWrapper = x; } } } else { targetWrapper = (XdmNode)XdmValue.Wrap(target); } if (targetWrapper == null) { throw new DynamicError("No element with id='" + fragment + "' found"); } return(Compile(targetWrapper)); } else if (hash > 0) { throw new NotImplementedException("href cannot identify an embedded stylesheet in a different document"); } else { Uri uri = new Uri(n.BaseUri, href); return(Compile(uri)); } } } throw new DynamicError("xml-stylesheet processing instruction not found"); }
public void Message(XdmNode content, bool terminate, IXmlLocation location) { Console.Out.WriteLine("MESSAGE terminate=" + (terminate ? "yes" : "no") + " at " + DateTime.Now); Console.Out.WriteLine("From instruction at line " + location.LineNumber + " of " + location.BaseUri); Console.Out.WriteLine(">>" + content.StringValue); }
private static QName makeQName(String lexical, XdmNode element) { if (lexical.IndexOf(":") >= 0) { return new QName(lexical, element); } else { return new QName("", lexical); } }
/// <summary> /// Supply the instance document to be validated in the form of an XdmNode /// </summary> /// <remarks> /// <para>The supplied node must be either a document node or an element node. /// If an element node is supplied, then the subtree rooted at this element is /// validated as if it were a complete document: that is, it must not only conform /// to the structure required of that element, but any referential constraints /// (keyref, IDREF) must be satisfied within that subtree. /// </para> /// </remarks> /// <param name="source">The document or element node at the root of the tree /// to be validated</param> public void SetSource(XdmNode source) { this.source = (NodeInfo)source.value; }
/// <summary> /// Serialize an XdmNode to the selected output destination using this serializer /// </summary> /// <param name="node">The node to be serialized</param> /// <remarks>since 9.8</remarks> public void SerializeXdmNode(XdmNode node) { net.sf.saxon.query.QueryResult.serialize(node.Implementation, GetResult(config.makePipelineConfiguration()), GetOutputProperties()); }
public XdmNodeWrapper(XdmNode node) { if (node == null) throw new ArgumentNullException("node"); this.node = node; }
public void Message(XdmNode content, bool terminate, IXmlLocation location) { string message = content.ToString(); Trace.WriteLine(message); }
private bool testAssertion(XdmNode assertion, Outcome outcome, XPathCompiler assertXpc, XPathCompiler catalogXpc, bool debug) { try { string tag = assertion.NodeName.LocalName; bool result = testAssertion2(assertion, outcome, assertXpc, catalogXpc, debug); if (debug && !("all-of".Equals(tag)) && !("any-of".Equals(tag))) { feedback.Message("Assertion " + tag + " (" + assertion.StringValue + ") " + (result ? " succeeded" : " failed"), false); if (tag.Equals("error")) { Console.WriteLine("Expected exception " + assertion.GetAttributeValue(new QName("code")) + ", got " + (outcome.isException() ? ((DynamicError)outcome.getException()).ErrorCode.ToString() : "success")); } } return result; } catch (Exception e) { //e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. return false; } }
/// <summary> /// Compile a stylesheet, located at an XdmNode. This may be a document node whose /// child is an <c>xsl:stylesheet</c> or <c>xsl:transform</c> element, or it may be /// the <c>xsl:stylesheet</c> or <c>xsl:transform</c> element itself. /// </summary> /// <param name="node">The document node or the outermost element node of the document /// containing the principal stylesheet module.</param> /// <returns>An <c>XsltExecutable</c> which represents the compiled stylesheet object. /// The XsltExecutable may be run as many times as required, in the same or a different /// thread. The <c>XsltExecutable</c> is not affected by any changes made to the <c>XsltCompiler</c> /// once it has been compiled.</returns> public XsltExecutable Compile(XdmNode node) { PreparedStylesheet pss = (PreparedStylesheet)factory.newTemplates((JNodeInfo)node.value, info); return new XsltExecutable(pss); }
public void WriteResultFilePreamble(Processor processor, XdmNode catalog, string date)/* throws IOException, SaxonApiException, XMLStreamException*/ { /// results = new StreamWriter(/*TODO saxonResultsDir + */"/results" // + processor.ProductVersion + "n.xml"); /*Writer resultWriter = new BufferedWriter(new FileWriter(new File(resultsDir + "/results" + Version.getProductVersion() + ".xml"))); Serializer serializer = processor.NewSerializer(resultWriter); serializer.setOutputProperty(Serializer.Property.METHOD, "xml"); serializer.setOutputProperty(Serializer.Property.INDENT, "yes"); serializer.setOutputProperty(Serializer.Property.SAXON_LINE_LENGTH, "120");*/ //results = serializer.GetResult();// .getXMLStreamWriter(); results = new StreamWriter(resultsDir + "/results" + processor.ProductVersion + "n.xml"); results.WriteLine("<FOTS-test-suite-result>"); // results.writeDefaultNamespace(RNS); results.WriteLine("<implementation name='Saxon-EE' version='" + processor.ProductVersion + "' anonymous-result-column='false' >"); // results.writeAttribute("version", Version.getProductVersion()); results.WriteLine("<organization name='http://www.saxonica.com/' anonymous='false' />"); results.WriteLine("<submitter name='ONeil Delpratt' email='*****@*****.**' />"); results.WriteLine("</implementation>"); //implementation results.WriteLine("<test-run date='" + date + "' testSuiteVersion='" + catalog.GetAttributeValue(new QName("test-suite")) + " " + catalog.GetAttributeValue(new QName("version")) + "'/>"); }
/** * Construct source object. This method allows subclassing e.g. to build a DOM or XOM source. * @param xml * @return * @throws XPathException */ protected XdmNode buildSource(XdmNode catalog, DocumentBuilder builder, String sourceName) { // Find the source element in the catalog XPathSelector xps = findSourcePath.Load(); xps.SetVariable(new QName("", "param"), new XdmAtomicValue(sourceName)); xps.ContextItem = catalog; XdmNode source = (XdmNode)xps.EvaluateSingle(); // decide whether schema validation is needed bool validate = source.GetAttributeValue(new QName("", "schema")) != null; if (validate) { builder.SchemaValidationMode = SchemaValidationMode.Strict; } else { builder.SchemaValidationMode = SchemaValidationMode.None; } // build the document tree from the source file string filename = testSuiteDir + "/" + source.GetAttributeValue(new QName("", "FileName")); if (source == null) { throw new ArgumentException("Source " + sourceName + " not found in catalog"); } return builder.Build(new Uri(filename)); }
private void processTestSet(DocumentBuilder catbuilder, XPathCompiler xpc, XdmNode funcSetNode) { string testName; try { results.WriteLine("<test-set name='" + funcSetNode.GetAttributeValue(new QName("name")) + "'>"); } catch (Exception e) { } string testSetFile = testSuiteDir + "\\" + funcSetNode.GetAttributeValue(new QName("file")); xpc.BaseUri = testSetFile; XdmNode testSetDocNode = catbuilder.Build(new Uri(testSetFile)); localEnvironments.Clear(); TestEnvironment defaultEnvironment = createLocalEnvironment(testSetDocNode.BaseUri); localEnvironments.Add("default", defaultEnvironment); bool run = true; IEnumerator dependency = xpc.Evaluate("/test-set/dependency", testSetDocNode).GetEnumerator(); while (dependency.MoveNext()) { if (!DependencyIsSatisfied((XdmNode)dependency.Current, defaultEnvironment)) { run = false; } } if (run) { IEnumerator iter = xpc.Evaluate("//environment[@name]", testSetDocNode).GetEnumerator(); while (iter.MoveNext()) { processEnvironment(xpc, (XdmNode)iter.Current, localEnvironments); } IEnumerator testCases = xpc.Evaluate("//test-case", testSetDocNode).GetEnumerator(); while (testCases.MoveNext()) { testName = ((XdmNode)xpc.EvaluateSingle("@name", (XdmItem)testCases.Current)).StringValue; if (testPattern != null && !testPattern.Match(testName).Success) { continue; } feedback.Message("Test set " + funcSetNode.GetAttributeValue(new QName("name")) + " ", false); runTestCase((XdmNode)testCases.Current, xpc); } } try { results.WriteLine("</test-set>"); } catch (Exception e) { } }
private XdmNode getChildElement(XdmNode parent, QName child) { IEnumerator e = parent.EnumerateAxis(XdmAxis.Child, child); return e.MoveNext() ? (XdmNode)e.Current : null; }
/** * Decide whether a dependency is satisfied * * @param dependency the dependency element in the catalog * @param env an environment in the catalog, which can be modified to satisfy the dependency if necessary. * May be null. * @return true if the environment satisfies the dependency, else false */ private bool DependencyIsSatisfied(XdmNode dependency, TestEnvironment env) { string type = dependency.GetAttributeValue(new QName("type")); string value = dependency.GetAttributeValue(new QName("value")); bool inverse = "false".Equals(dependency.GetAttributeValue(new QName("satisfied"))); if ("xml-version".Equals(type)) { if ("1.1".Equals(value) && !inverse) { if (env != null) { env.processor.XmlVersion = (decimal)1.1; } else { return false; } } return true; } else if ("xsd-version".Equals(type)) { if ("1.1".Equals(value)) { if (env != null) { env.processor.SetProperty(JFeatureKeys.XSD_VERSION, (inverse ? "1.0" : "1.1")); } else { return false; } } else if ("1.0".Equals(value)) { if (env != null) { env.processor.SetProperty(JFeatureKeys.XSD_VERSION, (inverse ? "1.1" : "1.0")); } else { return false; } } return true; } else if ("limits".Equals(type)) { if ("year_lt_0".Equals(value) && !inverse) { return true; } else { return false; } } else if ("spec".Equals(type)) { return true; } else if ("collection-stability".Equals(type)) { // SAXON has a problem here - we don't support stable collections return ("false".Equals(value) != inverse); } else if ("default-language".Equals(type)) { return ("en".Equals(value) != inverse); } else if ("directory-as-collection-Uri".Equals(type)) { return ("true".Equals(value) != inverse); } else if ("language".Equals(type)) { return (("en".Equals(value) || "de".Equals(value) || "fr".Equals(value)) != inverse); } else if ("calendar".Equals(type)) { return (("AD".Equals(value) || "ISO".Equals(value)) != inverse); } else if ("format-integer-sequence".Equals(type)) { return !inverse; } else if ("feature".Equals(type)) { if ("namespace-axis".Equals(value)) { return !inverse; } else if ("schemaImport".Equals(value) || "schemaValidation".Equals(value)) { // Need to reset these after use for this query?? if (env != null) { env.xpathCompiler.SchemaAware = true; env.xqueryCompiler.SchemaAware = true; } return true; } else if ("xpath-1.0-compatibility".Equals(value)) { if (env != null) { env.xpathCompiler.BackwardsCompatible = !inverse; return true; } else { return false; } } else if ("schema-location-hint".Equals(value)) { return !inverse; } else { Console.WriteLine("**** feature = " + value + " ????"); return false; } } else { Console.WriteLine("**** dependency not recognized: " + type); return false; } }
private IList getCollection(XdmNode collectionNode) { ArrayList list = new ArrayList(10); IEnumerator e = collectionNode.EnumerateAxis( XdmAxis.Child, new QName(testURI, "input-document")); while (e.MoveNext()) { XdmNode node = (XdmNode)e.Current; list.Add(new Uri(testSuiteDir + "/TestSources/" + node.StringValue + ".xml")); } return list; }
/// <summary> /// Serialize an <c>XdmNode</c> to the selected output destination using this serializer. /// </summary> /// <param name="node">The node to be serialized</param> /// <remarks>since 9.8</remarks> public void SerializeXdmNode(XdmNode node) { serializer.serializeNode((net.sf.saxon.s9api.XdmNode)XdmValue.FromGroundedValueToJXdmValue(node.value)); }
/// <summary> /// Supply the instance document to be validated in the form of an XdmNode /// </summary> /// <remarks> /// <para>The supplied node must be either a document node or an element node. /// If an element node is supplied, then the subtree rooted at this element is /// validated as if it were a complete document: that is, it must not only conform /// to the structure required of that element, but any referential constraints /// (keyref, IDREF) must be satisfied within that subtree. /// </para> /// </remarks> /// <param name="source">The document or element node at the root of the tree /// to be validated</param> public void SetSource(XdmNode source) { this.source = (JNodeInfo)source.value; sources.Clear(); }