/// <summary> /// Initialize this instance of DodSequenceMerge. /// </summary> public void Create(XmlQueryRuntime runtime) { _firstSequence = null; _sequencesToMerge = null; _nodeCount = 0; _runtime = runtime; }
/// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept Rtf content (top-level sequences are therefore prohibited). /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlEventCache xwrt) { this.runtime = runtime; this.xwrt = xwrt; this.xstate = XmlState.WithinContent; this.depth = 1; this.rootType = XPathNodeType.Root; }
internal XmlQueryContext(XmlQueryRuntime runtime, object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, WhitespaceRuleLookup wsRules) { this.runtime = runtime; this.dataSources = dataSources; this.dataSourceCache = new Hashtable(); this.argList = argList; this.wsRules = wsRules; if (defaultDataSource is XmlReader) { this.readerSettings = new QueryReaderSettings((XmlReader) defaultDataSource); } else { // Consider allowing users to set DefaultReaderSettings in XsltArgumentList // readerSettings = argList.DefaultReaderSettings; this.readerSettings = new QueryReaderSettings(new NameTable()); } if (defaultDataSource is string) { // Load the default document from a Uri this.defaultDataSource = GetDataSource(defaultDataSource as string, null); if (this.defaultDataSource == null) throw new XslTransformException(Res.XmlIl_UnknownDocument, defaultDataSource as string); } else if (defaultDataSource != null) { this.defaultDataSource = ConstructDocument(defaultDataSource, null, null); } }
/// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept Rtf content (top-level sequences are therefore prohibited). /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlEventCache xwrt) { _runtime = runtime; _xwrt = xwrt; _xstate = XmlState.WithinContent; _depth = 1; _rootType = XPathNodeType.Root; }
/// <summary> /// Initialize this instance of DodSequenceMerge. /// </summary> public void Create(XmlQueryRuntime runtime) { this.firstSequence = null; if (this.sequencesToMerge != null) this.sequencesToMerge.Clear(); this.nodeCount = 0; this.runtime = runtime; }
/// <summary> /// Create SetIterator. /// </summary> public void Create(XmlQueryRuntime runtime) { this.runtime = runtime; this.state = IteratorState.InitLeft; }
/// <summary> /// Create SetIterator. /// </summary> public void Create(XmlQueryRuntime runtime) { _runtime = runtime; _state = IteratorState.InitLeft; }
public static XmlAtomicValue BytesToAtomicValue(byte[] value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
/// <summary> /// Initialize the FollowingSiblingIterator. /// </summary> public void Create(XPathNavigator context, XmlNavigatorFilter filter) { _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, context); _filter = filter; }
public static XmlAtomicValue Int64ToAtomicValue(long value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
public static XmlAtomicValue XmlQualifiedNameToAtomicValue(XmlQualifiedName value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
public static XmlAtomicValue SingleToAtomicValue(float value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
private Dictionary<string, string> _usedPrefixes = new Dictionary<string, string>(); //The prefies that used in the current scope /// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept top-level sequences. /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlSequenceWriter seqwrt) { _runtime = runtime; _seqwrt = seqwrt; _xstate = XmlState.WithinSequence; }
public static XmlAtomicValue DecimalToAtomicValue(decimal value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
public static XmlAtomicValue Int64ToAtomicValue(long value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
internal XsltLibrary(XmlQueryRuntime runtime) { _runtime = runtime; }
public IteratorResult MoveNext(XPathNavigator input) { switch (_state) { case IteratorState.NeedCandidateCurrent: // If there are no more input nodes, then iteration is complete if (input == null) { return(IteratorResult.NoMoreNodes); } // Save input node as current node _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input); // Scan for additional input nodes within the same document (since they are after navCurrent in docorder) _state = IteratorState.HaveCandidateCurrent; return(IteratorResult.NeedInputNode); case IteratorState.HaveCandidateCurrent: // If there are no more input nodes, if (input == null) { // Then candidate node has been selected, and there are no further input nodes _state = IteratorState.HaveCurrentNoNext; } else { // If the input node is in the same document as the current node, if (_navCurrent.ComparePosition(input) != XmlNodeOrder.Unknown) { // Then update the current node and get the next input node _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input); return(IteratorResult.NeedInputNode); } // Save the input node as navNext _navNext = XmlQueryRuntime.SyncToNavigator(_navNext, input); _state = IteratorState.HaveCurrentHaveNext; } PushAncestors(); break; } if (!_navStack.IsEmpty) { while (true) { // Move to the next matching node that is before the top node on the stack in document order if (_filter.MoveToFollowing(_navCurrent, _navStack.Peek())) { // Found match return(IteratorResult.HaveCurrentNode); } // Do not include ancestor nodes as part of the preceding axis _navCurrent.MoveTo(_navStack.Pop()); // No more preceding matches possible if (_navStack.IsEmpty) { break; } } } if (_state == IteratorState.HaveCurrentNoNext) { // No more nodes, so iteration is complete _state = IteratorState.NeedCandidateCurrent; return(IteratorResult.NoMoreNodes); } // Make next node the current node and start trying to find input node greatest in docorder _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, _navNext); _state = IteratorState.HaveCandidateCurrent; return(IteratorResult.HaveCurrentNode); }
public IteratorResult MoveNext(XPathNavigator input) { switch (_state) { case IteratorState.NeedCandidateCurrent: // If there are no more input nodes, then iteration is complete if (input == null) { return(IteratorResult.NoMoreNodes); } // Save input node as current node _navCurrent = XmlQueryRuntime.SyncToNavigator(_navCurrent, input); // Still must check next input node to see if is a descendant of this one _state = IteratorState.HaveCandidateCurrent; return(IteratorResult.NeedInputNode); case IteratorState.HaveCandidateCurrent: // If there are no more input nodes, if (input == null) { // Then candidate node has been selected, and there are no further input nodes _state = IteratorState.HaveCurrentNoNext; return(MoveFirst()); } // If input node is in the subtree of the candidate node, then use the input node instead if (_navCurrent.IsDescendant(input)) { goto case IteratorState.NeedCandidateCurrent; } // Found node on which to perform following scan. Now skip past all input nodes in the same document. _state = IteratorState.HaveCurrentNeedNext; goto case IteratorState.HaveCurrentNeedNext; case IteratorState.HaveCurrentNeedNext: // If there are no more input nodes, if (input == null) { // Then candidate node has been selected, and there are no further input nodes _state = IteratorState.HaveCurrentNoNext; return(MoveFirst()); } // Skip input node unless it's in a different document than the node on which the following scan was performed if (_navCurrent.ComparePosition(input) != XmlNodeOrder.Unknown) { return(IteratorResult.NeedInputNode); } // Next node is in a different document, so save it _navNext = XmlQueryRuntime.SyncToNavigator(_navNext, input); _state = IteratorState.HaveCurrentHaveNext; return(MoveFirst()); } if (!_filter.MoveToFollowing(_navCurrent, null)) { return(MoveFailed()); } return(IteratorResult.HaveCurrentNode); }
internal XsltLibrary(XmlQueryRuntime runtime) { this.runtime = runtime; }
public static XmlAtomicValue XmlQualifiedNameToAtomicValue(XmlQualifiedName value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
private Dictionary<string, string> usedPrefixes = new Dictionary<string, string>(); //The prefies that used in the current scope /// <summary> /// This constructor is internal so that external users cannot construct it (and therefore we do not have to test it separately). /// Initialize output state to accept top-level sequences. /// </summary> internal XmlQueryOutput(XmlQueryRuntime runtime, XmlSequenceWriter seqwrt) { this.runtime = runtime; this.seqwrt = seqwrt; this.xstate = XmlState.WithinSequence; }
public static XmlAtomicValue TimeSpanToAtomicValue(TimeSpan value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
public static XmlAtomicValue DecimalToAtomicValue(decimal value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
/// <summary> /// Initialize this instance of DodSequenceMerge. /// </summary> public void Create(XmlQueryRuntime runtime) { this.firstSequence = null; this.sequencesToMerge = null; this.nodeCount = 0; this.runtime = runtime; }
public static XmlAtomicValue SingleToAtomicValue(float value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
public static XmlAtomicValue TimeSpanToAtomicValue(TimeSpan value, int index, XmlQueryRuntime runtime) { return new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value); }
/// <summary> /// Position this iterator to the next content or sibling node. Return IteratorResult.NoMoreNodes if there are /// no more content or sibling nodes. Return IteratorResult.NeedInputNode if the next input node needs to be /// fetched first. Return IteratorResult.HaveCurrent if the Current property is set to the next node in the /// iteration. /// </summary> internal IteratorResult MoveNext(XPathNavigator input, bool isContent) { switch (this.state) { case IteratorState.NeedCurrent: // If there are no more input nodes, then iteration is complete if (input == null) { return(IteratorResult.NoMoreNodes); } // Save the input node as the current node this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, input); // If matching child or sibling is found, then we have a current node if (isContent ? this.filter.MoveToContent(this.navCurrent) : this.filter.MoveToFollowingSibling(this.navCurrent)) { this.state = IteratorState.HaveCurrentNeedNext; } return(IteratorResult.NeedInputNode); case IteratorState.HaveCurrentNeedNext: if (input == null) { // There are no more input nodes, so enter HaveCurrentNoNext state and return Current this.state = IteratorState.HaveCurrentNoNext; return(IteratorResult.HaveCurrentNode); } // Save the input node as the next node this.navNext = XmlQueryRuntime.SyncToNavigator(this.navNext, input); // If matching child or sibling is found, if (isContent ? this.filter.MoveToContent(this.navNext) : this.filter.MoveToFollowingSibling(this.navNext)) { // Then compare position of current and next nodes this.state = IteratorState.HaveCurrentHaveNext; return(DocOrderMerge()); } // Input node does not result in matching child or sibling, so get next input node return(IteratorResult.NeedInputNode); case IteratorState.HaveCurrentNoNext: case IteratorState.HaveCurrentHaveNext: // If the current node has no more matching siblings, if (isContent ? !this.filter.MoveToNextContent(this.navCurrent) : !this.filter.MoveToFollowingSibling(this.navCurrent)) { if (this.navStack.IsEmpty) { if (this.state == IteratorState.HaveCurrentNoNext) { // No more input nodes, so iteration is complete return(IteratorResult.NoMoreNodes); } // Make navNext the new current node and fetch a new navNext this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, this.navNext); this.state = IteratorState.HaveCurrentNeedNext; return(IteratorResult.NeedInputNode); } // Pop new current node from the stack this.navCurrent = this.navStack.Pop(); } // If there is no next node, then no need to call DocOrderMerge; just return the current node if (this.state == IteratorState.HaveCurrentNoNext) { return(IteratorResult.HaveCurrentNode); } // Compare positions of current and next nodes return(DocOrderMerge()); } Debug.Assert(false, "Invalid IteratorState " + this.state); return(IteratorResult.NoMoreNodes); }
public static XmlAtomicValue BytesToAtomicValue(byte[] value, int index, XmlQueryRuntime runtime) { return(new XmlAtomicValue(runtime.GetXmlType(index).SchemaType, value)); }
public IList <XPathItem> InvokeXsltLateBoundFunction(string name, string namespaceUri, IList <XPathItem>[] args) { object instance; object[] objActualArgs; XmlQueryType xmlTypeFormalArg; Type clrTypeFormalArg; object objRet; // Get external object instance from argument list (throw if either the list or the instance doesn't exist) instance = (_argList != null) ? _argList.GetExtensionObject(namespaceUri) : null; if (instance == null) { throw new XslTransformException(SR.XmlIl_UnknownExtObj, namespaceUri); } // Bind to a method on the instance object if (_extFuncsLate == null) { _extFuncsLate = new XmlExtensionFunctionTable(); } // Bind to the instance, looking for a matching method (throws if no matching method) XmlExtensionFunction extFunc = _extFuncsLate.Bind(name, namespaceUri, args.Length, instance.GetType(), XmlQueryRuntime.LateBoundFlags); // Create array which will contain the actual arguments objActualArgs = new object[args.Length]; for (int i = 0; i < args.Length; i++) { // 1. Assume that the input value can only have one of the following 5 Xslt types: // xs:double, xs:string, xs:boolean, node* (can be rtf) // 2. Convert each Rtf value to a NodeSet containing one node. Now the value may only have one of the 4 Xslt types. // 3. Convert from one of the 4 Xslt internal types to the Xslt internal type which is closest to the formal // argument's Xml type (inferred from the Clr type of the formal argument). xmlTypeFormalArg = extFunc.GetXmlArgumentType(i); switch (xmlTypeFormalArg.TypeCode) { case XmlTypeCode.Boolean: objActualArgs[i] = XsltConvert.ToBoolean(args[i]); break; case XmlTypeCode.Double: objActualArgs[i] = XsltConvert.ToDouble(args[i]); break; case XmlTypeCode.String: objActualArgs[i] = XsltConvert.ToString(args[i]); break; case XmlTypeCode.Node: if (xmlTypeFormalArg.IsSingleton) { objActualArgs[i] = XsltConvert.ToNode(args[i]); } else { objActualArgs[i] = XsltConvert.ToNodeSet(args[i]); } break; case XmlTypeCode.Item: objActualArgs[i] = args[i]; break; default: Debug.Fail($"This XmlTypeCode should never be inferred from a Clr type: {xmlTypeFormalArg.TypeCode}"); break; } // 4. Change the Clr representation to the Clr type of the formal argument clrTypeFormalArg = extFunc.GetClrArgumentType(i); if (xmlTypeFormalArg.TypeCode == XmlTypeCode.Item || !clrTypeFormalArg.IsAssignableFrom(objActualArgs[i].GetType())) { objActualArgs[i] = XmlQueryRuntime.ChangeTypeXsltArgument(xmlTypeFormalArg, objActualArgs[i], clrTypeFormalArg); } } // 1. Invoke the late bound method objRet = extFunc.Invoke(instance, objActualArgs); // 2. Convert to IList<XPathItem> if (objRet == null && extFunc.ClrReturnType == XsltConvert.VoidType) { return(XmlQueryNodeSequence.Empty); } return((IList <XPathItem>)_runtime.ChangeTypeXsltResult(XmlQueryTypeFactory.ItemS, objRet)); }
/// <summary> /// Initialize the ContentIterator. /// </summary> public void Create(XPathNavigator context) { this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context); this.needFirst = true; }
public void Create(XPathNavigator context, string value) { this.navCurrent = XmlQueryRuntime.SyncToNavigator(this.navCurrent, context); this.idrefs = XmlConvert.SplitString(value); this.idx = -1; }