本文整理汇总了C#中System.Xml.XPath.XPathItem类的典型用法代码示例。如果您正苦于以下问题:C# XPathItem类的具体用法?C# XPathItem怎么用?C# XPathItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathItem类属于System.Xml.XPath命名空间,在下文中一共展示了XPathItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToBoolean
//------------------------------------------------------------------------
// ToBoolean (internal type to internal type)
//------------------------------------------------------------------------
public static bool ToBoolean(XPathItem item)
{
XsltLibrary.CheckXsltValue(item);
if (item.IsNode)
return true;
Type itemType = item.ValueType;
if (itemType == StringType)
{
return item.Value.Length != 0;
}
else if (itemType == DoubleType)
{
// (x < 0 || 0 < x) == (x != 0) && !Double.IsNaN(x)
double dbl = item.ValueAsDouble;
return dbl < 0 || 0 < dbl;
}
else
{
Debug.Assert(itemType == BooleanType, "Unexpected type of atomic sequence " + itemType.ToString());
return item.ValueAsBoolean;
}
}
示例2: XQueryContextManager
internal XQueryContextManager (XQueryStaticContext ctx, XPathItem input, XmlWriter writer, XmlResolver resolver, XmlArgumentList args)
{
this.input = input;
this.staticContext = ctx;
this.args = args;
currentWriter = writer;
this.extDocResolver = resolver;
namespaceManager = new XmlNamespaceManager (ctx.NameTable);
foreach (DictionaryEntry de in ctx.NSResolver.GetNamespacesInScope (XmlNamespaceScope.ExcludeXml))
namespaceManager.AddNamespace (de.Key.ToString (), de.Value.ToString ());
namespaceManager.PushScope ();
currentContext = new XQueryContext (this, null, new Hashtable ());
if (input != null) {
currentSequence = new SingleItemIterator (input, currentContext);
currentSequence.MoveNext ();
}
currentContext = new XQueryContext (this, currentSequence, new Hashtable ());
}
示例3: Add
public void Add(XPathItem item)
{
XQueryNavigator nav = item as XQueryNavigator;
if (nav != null && nav.NodeType == XPathNodeType.Element)
{
if (current == null || current.document != nav.Document)
{
current = new ElementsSegment(nav.Document);
segments.Add(current);
}
current.Add(nav.Position);
}
else
{
if (current == null || current.document != null)
{
current = new DataSegment();
segments.Add(current);
}
current.Add(item.Clone());
}
count++;
}
示例4: ItemEqual
private bool ItemEqual(XPathItem item1, XPathItem item2)
{
object res;
object x = item1.TypedValue;
if (x is UntypedAtomic || x is AnyUriValue)
x = x.ToString();
object y = item2.TypedValue;
if (y is UntypedAtomic || y is AnyUriValue)
y = x.ToString();
if (x is Single && Single.IsNaN((float)x) ||
x is Double && Double.IsNaN((double)x))
x = Double.NaN;
if (y is Single && Single.IsNaN((float)y) ||
y is Double && Double.IsNaN((double)y))
y = Double.NaN;
if (x.Equals(y))
return true;
if (ValueProxy.Eq(x, y, out res))
{
if (res != null)
return true;
}
return false;
}
示例5: FnIndexOf
public static XPathSequence FnIndexOf (XQueryContext ctx, XPathSequence items, XPathItem item, CultureInfo ci)
{
ArrayList al = new ArrayList ();
IEnumerator e = items.GetEnumerator ();
for (int i = 0; e.MoveNext (); i++) {
XPathItem iter = e.Current as XPathItem;
if (iter.XmlType.TypeCode == XmlTypeCode.String) {
if (ci.CompareInfo.Compare (iter.Value, item.Value) == 0)
al.Add (i);
}
else {
IComparable ic = (IComparable) iter.TypedValue;
if (ic.CompareTo ((IComparable) item.TypedValue) == 0)
al.Add (i);
}
}
return new ListIterator (ctx, al);
}
示例6: FnSum
public static object FnSum (XPathSequence e, XPathItem zero)
{
throw new NotImplementedException ();
}
示例7: ItemToTime
public static DateTime ItemToTime (XPathItem value)
{
return XmlConvert.ToDateTime (value.Value);
}
示例8: ItemToQName
public static XmlQualifiedName ItemToQName (XPathItem value)
{
return (XmlQualifiedName) value.TypedValue;
}
示例9: ItemToNonPositiveInteger
public static decimal ItemToNonPositiveInteger (XPathItem value)
{
return XmlConvert.ToDecimal (value.Value);
}
示例10: ItemToInteger
public static long ItemToInteger (XPathItem value)
{
return XmlConvert.ToInt64 (value.Value);
}
示例11: ItemToAnyUri
public static string ItemToAnyUri (XPathItem value)
{
return value.Value;
}
示例12: ItemToUnsignedLong
public static decimal ItemToUnsignedLong (XPathItem value)
{
return XmlConvert.ToInt32 (value.Value);
}
示例13: CreateXmlType
/// <summary>
/// Create an XmlQueryType that represents the type of "item".
/// </summary>
private XmlQueryType CreateXmlType(XPathItem item) {
if (item.IsNode) {
// Rtf
RtfNavigator rtf = item as RtfNavigator;
if (rtf != null)
return XmlQueryTypeFactory.Node;
// Node
XPathNavigator nav = (XPathNavigator) item;
switch (nav.NodeType) {
case XPathNodeType.Root:
case XPathNodeType.Element:
if (nav.XmlType == null)
return XmlQueryTypeFactory.Type(nav.NodeType, XmlQualifiedNameTest.New(nav.LocalName, nav.NamespaceURI), XmlSchemaComplexType.UntypedAnyType, false);
return XmlQueryTypeFactory.Type(nav.NodeType, XmlQualifiedNameTest.New(nav.LocalName, nav.NamespaceURI), nav.XmlType, nav.SchemaInfo.SchemaElement.IsNillable);
case XPathNodeType.Attribute:
if (nav.XmlType == null)
return XmlQueryTypeFactory.Type(nav.NodeType, XmlQualifiedNameTest.New(nav.LocalName, nav.NamespaceURI), DatatypeImplementation.UntypedAtomicType, false);
return XmlQueryTypeFactory.Type(nav.NodeType, XmlQualifiedNameTest.New(nav.LocalName, nav.NamespaceURI), nav.XmlType, false);
}
return XmlQueryTypeFactory.Type(nav.NodeType, XmlQualifiedNameTest.Wildcard, XmlSchemaComplexType.AnyType, false);
}
// Atomic value
return XmlQueryTypeFactory.Type((XmlSchemaSimpleType)item.XmlType, true);
}
示例14: MatchesXmlType
/// <summary>
/// Return true if the type of "item" is a subtype of the type identified by "code".
/// </summary>
public bool MatchesXmlType(XPathItem item, XmlTypeCode code) {
// All atomic type codes appear after AnyAtomicType
if (code > XmlTypeCode.AnyAtomicType)
return !item.IsNode && item.XmlType.TypeCode == code;
// Handle node code and AnyAtomicType
switch (code) {
case XmlTypeCode.AnyAtomicType: return !item.IsNode;
case XmlTypeCode.Node: return item.IsNode;
case XmlTypeCode.Item: return true;
default:
if (!item.IsNode)
return false;
switch (((XPathNavigator) item).NodeType) {
case XPathNodeType.Root: return code == XmlTypeCode.Document;
case XPathNodeType.Element: return code == XmlTypeCode.Element;
case XPathNodeType.Attribute: return code == XmlTypeCode.Attribute;
case XPathNodeType.Namespace: return code == XmlTypeCode.Namespace;
case XPathNodeType.Text: return code == XmlTypeCode.Text;
case XPathNodeType.SignificantWhitespace: return code == XmlTypeCode.Text;
case XPathNodeType.Whitespace: return code == XmlTypeCode.Text;
case XPathNodeType.ProcessingInstruction: return code == XmlTypeCode.ProcessingInstruction;
case XPathNodeType.Comment: return code == XmlTypeCode.Comment;
}
break;
}
Debug.Fail("XmlTypeCode " + code + " was not fully handled.");
return false;
}
示例15: ItemToHexBinary
public static byte [] ItemToHexBinary (XPathItem value)
{
return XmlConvert.FromBinHexString (value.Value);
}