本文整理汇总了C#中System.Xml.XPath.XPathItem类的典型用法代码示例。如果您正苦于以下问题:C# XPathItem类的具体用法?C# XPathItem怎么用?C# XPathItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathItem类属于System.Xml.XPath命名空间,在下文中一共展示了XPathItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:geoffkizer,项目名称:corefx,代码行数:29,代码来源:XsltConvert.cs
示例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 ());
}
开发者ID:Profit0004,项目名称:mono,代码行数:20,代码来源:XQueryContext.cs
示例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++;
}
开发者ID:,项目名称:,代码行数:23,代码来源:
示例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;
}
开发者ID:,项目名称:,代码行数:24,代码来源:
示例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);
}
开发者ID:Profit0004,项目名称:mono,代码行数:18,代码来源:XQueryFunctionCliImpl.cs
示例6: FnSum
public static object FnSum (XPathSequence e, XPathItem zero)
{
throw new NotImplementedException ();
}
开发者ID:Profit0004,项目名称:mono,代码行数:4,代码来源:XQueryFunctionCliImpl.cs
示例7: ItemToTime
public static DateTime ItemToTime (XPathItem value)
{
return XmlConvert.ToDateTime (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例8: ItemToQName
public static XmlQualifiedName ItemToQName (XPathItem value)
{
return (XmlQualifiedName) value.TypedValue;
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例9: ItemToNonPositiveInteger
public static decimal ItemToNonPositiveInteger (XPathItem value)
{
return XmlConvert.ToDecimal (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例10: ItemToInteger
public static long ItemToInteger (XPathItem value)
{
return XmlConvert.ToInt64 (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例11: ItemToAnyUri
public static string ItemToAnyUri (XPathItem value)
{
return value.Value;
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例12: ItemToUnsignedLong
public static decimal ItemToUnsignedLong (XPathItem value)
{
return XmlConvert.ToInt32 (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例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);
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:33,代码来源:xmlqueryruntime.cs
示例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;
}
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:34,代码来源:xmlqueryruntime.cs
示例15: ItemToHexBinary
public static byte [] ItemToHexBinary (XPathItem value)
{
return XmlConvert.FromBinHexString (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例16: ItemToInt
public static int ItemToInt (XPathItem value)
{
return XmlConvert.ToInt32 (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例17: ItemToBase64Binary
public static byte [] ItemToBase64Binary (XPathItem value)
{
return Convert.FromBase64String (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例18: ItemToItem
public static XPathItem ItemToItem (XPathItem value, XmlSchemaType schemaTypeDest)
{
return new XPathAtomicValue (value.Value, schemaTypeDest);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例19: ItemToBoolean
public static bool ItemToBoolean (XPathItem value)
{
return XmlConvert.ToBoolean (value.Value);
}
开发者ID:nlhepler,项目名称:mono,代码行数:4,代码来源:XQueryConvert.cs
示例20: CanConvert
// See XQuery & XPath 2.0 functions & operators section 17.
public static bool CanConvert (XPathItem item, XmlSchemaType schemaTypeDest)
{
if (item == null)
throw new ArgumentNullException ("item");
if (schemaTypeDest == null)
throw new ArgumentNullException ("schemaTypeDest");
XmlTypeCode src = item.XmlType.TypeCode;
XmlTypeCode dst = schemaTypeDest.TypeCode;
// Notation cannot be converted from other than Notation
if (src == XmlTypeCode.Notation && dst != XmlTypeCode.Notation)
return false;
// untypedAtomic and string are convertable unless source type is QName.
switch (dst) {
case XmlTypeCode.UntypedAtomic:
case XmlTypeCode.String:
return src != XmlTypeCode.QName;
}
switch (src) {
case XmlTypeCode.None:
case XmlTypeCode.Item:
case XmlTypeCode.Node:
case XmlTypeCode.Document:
case XmlTypeCode.Element:
case XmlTypeCode.Attribute:
case XmlTypeCode.Namespace:
case XmlTypeCode.ProcessingInstruction:
case XmlTypeCode.Comment:
case XmlTypeCode.Text:
throw new NotImplementedException (); // FIXME: check what happens
case XmlTypeCode.AnyAtomicType:
throw new NotImplementedException (); // FIXME: check what happens
case XmlTypeCode.UntypedAtomic:
case XmlTypeCode.String:
// 'M'
throw new NotImplementedException (); // FIXME: check what happens
case XmlTypeCode.Boolean:
case XmlTypeCode.Decimal:
switch (dst) {
case XmlTypeCode.Float:
case XmlTypeCode.Double:
case XmlTypeCode.Decimal:
case XmlTypeCode.Boolean:
return true;
}
return false;
case XmlTypeCode.Float:
case XmlTypeCode.Double:
if (dst == XmlTypeCode.Decimal)
// 'M'
throw new NotImplementedException (); // FIXME: check what happens
goto case XmlTypeCode.Decimal;
case XmlTypeCode.Duration:
switch (dst) {
case XmlTypeCode.Duration:
case XmlTypeCode.YearMonthDuration:
case XmlTypeCode.DayTimeDuration:
return true;
}
return false;
case XmlTypeCode.DateTime:
switch (dst) {
case XmlTypeCode.DateTime:
case XmlTypeCode.Time:
case XmlTypeCode.Date:
case XmlTypeCode.GYearMonth:
case XmlTypeCode.GYear:
case XmlTypeCode.GMonthDay:
case XmlTypeCode.GDay:
case XmlTypeCode.GMonth:
return true;
}
return false;
case XmlTypeCode.Time:
switch (dst) {
case XmlTypeCode.Time:
case XmlTypeCode.Date:
return true;
}
return false;
case XmlTypeCode.Date:
if (dst == XmlTypeCode.Time)
return false;
goto case XmlTypeCode.DateTime;
case XmlTypeCode.GYearMonth:
case XmlTypeCode.GYear:
case XmlTypeCode.GMonthDay:
case XmlTypeCode.GDay:
case XmlTypeCode.GMonth:
//.........这里部分代码省略.........
开发者ID:nlhepler,项目名称:mono,代码行数:101,代码来源:XQueryConvert.cs
注:本文中的System.Xml.XPath.XPathItem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论