예제 #1
0
        private void WriteQName(string name, string ns, NSResolver nss)
        {
            string prefix = String.Empty;

            if (ns != null && ns != String.Empty)
            {
#if NET_2_0
#else
                // XmlNamespaceManager sucks.
                ns = nss.NameTable.Add(ns);
#endif
                prefix = nss.LookupPrefix(ns);
            }
            if (prefix == null)
            {
                throw new RelaxngException(String.Format("Namespace '{0}' is not mapped to a prefix in argument XmlNamespaceManager.", ns));
            }
            if (prefix != String.Empty)
            {
                w.Write(prefix);
                w.Write(':');
            }
            if (IsKeyword(name))
            {
                w.Write('\\');
            }
            w.Write(name);
        }
예제 #2
0
        BaseIterator ToBaseIterator(XPathNodeIterator iter, NSResolver ctx)
        {
            BaseIterator i = iter as BaseIterator;

            if (i == null)
            {
                i = new WrapperIterator(iter, ctx);
            }
            return(i);
        }
예제 #3
0
파일: RncWriter.cs 프로젝트: runefs/Marvin
		private XmlNameTable GetNameTable (NSResolver nss1, NSResolver nss2)
		{
			XmlNameTable nt = null;
			if (nss1 is XmlNamespaceManager)
				nt = ((XmlNamespaceManager) nss1).NameTable;
			if (nss2 is XmlNamespaceManager)
				nt = ((XmlNamespaceManager) nss2).NameTable;
			if (nt == null)
				nt = new NameTable ();
			return nt;
		}
예제 #4
0
파일: RncWriter.cs 프로젝트: runefs/Marvin
		public RncWriter (TextWriter writer, NSResolver structureNamespaces, NSResolver dataNamespaces)
		{
			this.w = writer;
			this.nsmgr = structureNamespaces;
			this.datansmgr = dataNamespaces;
			XmlNameTable nt = GetNameTable (nsmgr, datansmgr);
			if (nsmgr == null)
				nsmgr = new XmlNamespaceManager (nt);
			if (datansmgr == null)
				datansmgr = new XmlNamespaceManager (nt);
		}
예제 #5
0
        internal XPathNodeIterator Select(XPathExpression expr, NSResolver ctx)
        {
            CompiledExpression cexpr = (CompiledExpression)expr;

            if (ctx == null)
            {
                ctx = cexpr.NamespaceManager;
            }

            BaseIterator iter = new NullIterator(this, ctx);

            return(cexpr.EvaluateNodeSet(iter));
        }
예제 #6
0
        public void WriteNamespaces(string defaultNamespace, NSResolver nsmgr, bool isData)
        {
            if (defaultNamespace == null)
            {
                defaultNamespace = String.Empty;
            }

            if (defaultNamespace.Length > 0)
            {
                w.WriteLine("default namespace = {0}",
                            defaultNamespace);
            }

            if (nsmgr != null)
            {
#if NET_2_0
                foreach (string s in nsmgr.GetNamespacesInScope(
                             XmlNamespaceScope.All).Keys)
                {
#else
                foreach (string s in nsmgr)
                {
#endif
                    switch (s)
                    {
                    case "xml":
                    case "xmlns":
                        continue;

                    case "":
                        if (defaultNamespace.Length > 0)
                        {
                            w.WriteLine("default namespace = '{0}'",
                                        nsmgr.LookupNamespace(s).Replace('\'', '\"'));
                        }
                        break;

                    default:
                        w.WriteLine("{2} {0} = '{1}'",
                                    s,
                                    nsmgr.LookupNamespace(s).Replace('\'', '\"'),
                                    isData ? "datatypes" : "namespace");
                        break;
                    }
                }
            }
            w.WriteLine();
        }
예제 #7
0
        public RncWriter(TextWriter writer, NSResolver structureNamespaces, NSResolver dataNamespaces)
        {
            this.w         = writer;
            this.nsmgr     = structureNamespaces;
            this.datansmgr = dataNamespaces;
            XmlNameTable nt = GetNameTable(nsmgr, datansmgr);

            if (nsmgr == null)
            {
                nsmgr = new XmlNamespaceManager(nt);
            }
            if (datansmgr == null)
            {
                datansmgr = new XmlNamespaceManager(nt);
            }
        }
예제 #8
0
        object Evaluate(XPathExpression expr, XPathNodeIterator context, NSResolver ctx)
        {
            CompiledExpression cexpr = (CompiledExpression)expr;

            if (ctx == null)
            {
                ctx = cexpr.NamespaceManager;
            }

            if (context == null)
            {
                context = new NullIterator(this, ctx);
            }
            BaseIterator iterContext = ToBaseIterator(context, ctx);

            iterContext.NamespaceManager = ctx;
            return(cexpr.Evaluate(iterContext));
        }
예제 #9
0
        private XmlNameTable GetNameTable(NSResolver nss1, NSResolver nss2)
        {
            XmlNameTable nt = null;

            if (nss1 is XmlNamespaceManager)
            {
                nt = ((XmlNamespaceManager)nss1).NameTable;
            }
            if (nss2 is XmlNamespaceManager)
            {
                nt = ((XmlNamespaceManager)nss2).NameTable;
            }
            if (nt == null)
            {
                nt = new NameTable();
            }
            return(nt);
        }
예제 #10
0
 internal BaseIterator(BaseIterator other)
 {
     _nsm     = other._nsm;
     position = other.position;
 }
예제 #11
0
 public NullIterator(XPathNavigator nav, NSResolver nsm) : base(nav, nsm)
 {
 }
예제 #12
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return new UriValueType ((XmlSchemaUri) ParseValue (s, nameTable, nsmgr));
		}
예제 #13
0
 public RncWriter(TextWriter writer, NSResolver nsmgr)
     : this(writer, nsmgr, defaultNamespaceManager)
 {
 }
예제 #14
0
        // In this method, attributes are ignored.
        // It might throw Exception.
        public void ProcessMatch(bool isAttribute, ArrayList qnameStack, object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo li, int depth, string attrName, string attrNS, object attrValue, bool isXsiNil, ArrayList currentKeyFieldConsumers)
        {
            for (int i = 0; i < KeyFields.Count; i++)
            {
                XsdKeyEntryField keyField = KeyFields [i];
                XsdIdentityPath  path     = keyField.Matches(isAttribute, sender, nameTable, qnameStack, sourceUri, schemaType, nsResolver, li, depth, attrName, attrNS, attrValue);
                if (path == null)
                {
                    continue;
                }

                if (keyField.FieldFound)
                {
                    // HACK: This is not logical by nature. Attributes never be cosuming,
                    // so I used it as a temporary mark to sign it is *just* validated now.
                    if (!keyField.Consuming)
                    {
                        throw new ValException("Two or more matching field was found.",
                                               sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
                    }
                    else
                    {
                        keyField.Consuming = false;
                    }
                }
                if (keyField.Consumed)
                {
                    continue;
                }

                if (isXsiNil && !keyField.SetIdentityField(Guid.Empty, true, XsdAnySimpleType.Instance, depth, li))
                {
                    throw new ValException("Two or more identical field was found.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
                }
                XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType;
                if (ct != null &&
                    (ct.ContentType == XmlSchemaContentType.Empty || ct.ContentType == XmlSchemaContentType.ElementOnly) &&
                    schemaType != XmlSchemaComplexType.AnyType)
                {
                    throw new ValException("Specified schema type is complex type, which is not allowed for identity constraints.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
                }
                keyField.FieldFound      = true;
                keyField.FieldFoundPath  = path;
                keyField.FieldFoundDepth = depth;
                keyField.Consuming       = true;
                if (li != null && li.HasLineInfo())
                {
                    keyField.FieldHasLineInfo  = true;
                    keyField.FieldLineNumber   = li.LineNumber;
                    keyField.FieldLinePosition = li.LinePosition;
                }
                currentKeyFieldConsumers.Add(keyField);
            }
        }
예제 #15
0
파일: Iterator.cs 프로젝트: cyplo/mono
		internal BaseIterator (BaseIterator other)
		{
			_nsm = other._nsm;
			position = other.position;
		}
예제 #16
0
        private void FillAttributeFieldValue(object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, object identity, IXmlLineInfo lineInfo, int depth)
        {
            if (this.FieldFound)
            {
                throw new ValException(String.Format("The key value was already found as '{0}'{1}.", Identity,
                                                     (this.FieldHasLineInfo ?
                                                      String.Format(CultureInfo.InvariantCulture, " at line {0}, position {1}", FieldLineNumber, FieldLinePosition) :
                                                      "")),
                                       sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, null);
            }
            XmlSchemaDatatype   dt = schemaType as XmlSchemaDatatype;
            XmlSchemaSimpleType st = schemaType as XmlSchemaSimpleType;

            if (dt == null && st != null)
            {
                dt = st.Datatype;
            }
            try {
                if (!this.SetIdentityField(identity, false, dt as XsdAnySimpleType, depth, lineInfo))
                {
                    throw new ValException("Two or more identical field was found.",
                                           sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, null);
                }
                // HACK: This is not logical. Attributes will never be "cosuming",
                // so I used it as a temporary mark to sign it is validated *just now*.
                this.Consuming  = true;
                this.FieldFound = true;
            } catch (Exception ex) {
                throw new ValException("Failed to read typed value.", sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, ex);
            }
        }
예제 #17
0
		public override object ParseValue (string value, XmlNameTable nt, NSResolver nsmgr)
		{
			return GetValidatedArray (value, nt);
		}
예제 #18
0
		public override object ParseValue (string s, XmlNameTable nt, NSResolver nsmgr)
		{
			if (!XmlChar.IsNCName (s))
				throw new ArgumentException ("'" + s + "' is an invalid NCName.");
			return s;
		}
예제 #19
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return new StringValueType (ParseValue (s, nameTable, nsmgr) as string);
		}
예제 #20
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return DateTime.ParseExact (Normalize(s), "---dd", null);
		}
예제 #21
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			DateTime ret;
			return DateTime.TryParseExact (Normalize(s), "--MM", null, DateTimeStyles.RoundtripKind, out ret) ? ret : DateTime.ParseExact (Normalize(s), "--MM--", null);
		}
예제 #22
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return DateTime.ParseExact (Normalize (s), timeFormats, null, DateTimeStyles.None);
		}
예제 #23
0
        protected override void ParseConfiguration(System.Xml.XPath.XPathNavigator configurationElement, System.Xml.IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
        {
            base.ParseConfiguration(configurationElement, xmlNamespaceResolver, contentType);

            //<Enabled>true|false</Enabled>
            //<AdminEmail>[email protected]</AdminEmail>
            //<RequireUniqueEmail>true|false</RequireUniqueEmail>
            //<MailDefinition>...</MailDefinition>
            //<IsBodyHtml>true|false</IsBodyHtml>
            //<MailSubject>...</MailSubject>
            //<MailPriority>Low|Normal|High</MailPriority>
            //<MailFrom>[email protected]</MailFrom>
            foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
            {
                switch (node.LocalName)
                {
                case EnabledName:
                    bool enabled;
                    if (Boolean.TryParse(node.InnerXml, out enabled))
                    {
                        _enabled = enabled;
                    }
                    break;

                case AdminEmailName:
                    _adminEmail = node.InnerXml;
                    break;

                case RequireUniqueEmailName:
                    bool requireUniqueEmail;
                    if (Boolean.TryParse(node.InnerXml, out requireUniqueEmail))
                    {
                        _requireUniqueEmail = requireUniqueEmail;
                    }
                    break;

                case MailDefinitionName:
                    _mailDefinition = node.InnerXml;
                    break;

                case IsBodyHtmlName:
                    bool isBodyHtml;
                    if (Boolean.TryParse(node.InnerXml, out isBodyHtml))
                    {
                        _isBodyHtml = isBodyHtml;
                    }
                    break;

                case MailSubjectName:
                    _mailSubject = node.InnerXml;
                    break;

                case MailPriorityName:
                    if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.Low))
                    {
                        _mailPriority = MailPriority.Low;
                    }
                    else if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.Normal))
                    {
                        _mailPriority = MailPriority.Normal;
                    }
                    else if (node.InnerXml == Enum.GetName(typeof(MailPriority), MailPriority.High))
                    {
                        _mailPriority = MailPriority.High;
                    }
                    else
                    {
                        _mailPriority = MailPriority.Normal;
                    }
                    break;

                case MailFromName:
                    _mailFrom = node.InnerXml;
                    break;
                }
            }
        }
예제 #24
0
        internal bool EvaluateBoolean(XPathExpression expr, XPathNodeIterator context, NSResolver ctx)
        {
            CompiledExpression cexpr = (CompiledExpression)expr;

            if (ctx == null)
            {
                ctx = cexpr.NamespaceManager;
            }

            if (context == null)
            {
                context = new NullIterator(this, cexpr.NamespaceManager);
            }
            BaseIterator iterContext = (BaseIterator)context;

            iterContext.NamespaceManager = ctx;
            return(cexpr.EvaluateBoolean(iterContext));
        }
예제 #25
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return new StringArrayValueType (GetValidatedArray (s, nameTable));
		}
예제 #26
0
파일: Iterator.cs 프로젝트: cyplo/mono
		public ParentIterator (XPathNavigator nav, NSResolver nsm) : base (nav, nsm) {}
예제 #27
0
		public override object ParseValue (string s,
			XmlNameTable nameTable, NSResolver nsmgr)
		{
			return Normalize (s);
		}
예제 #28
0
파일: Iterator.cs 프로젝트: cyplo/mono
		internal BaseIterator (NSResolver nsm)
		{
			_nsm = nsm;
		}
예제 #29
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			decimal d = XmlConvert.ToDecimal (Normalize (s));
			if (Decimal.Floor (d) != d)
				throw new FormatException ("Integer contains point number.");
			return d;
		}
예제 #30
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return new QNameValueType (ParseValue (s, nameTable, nsmgr) as XmlQualifiedName);
		}
예제 #31
0
 public ListIterator(IList list, NSResolver nsm) : base(nsm)
 {
     _list = list;
 }
예제 #32
0
//		[CLSCompliant (false)]
		public override object ParseValue (string s,
			XmlNameTable nameTable, NSResolver nsmgr)
		{
			return ParseValueType (s, nameTable, nsmgr);
		}
예제 #33
0
		public override object ParseValue (string s,
			XmlNameTable nameTable, NSResolver nsmgr)
		{
			return new XmlSchemaUri (Normalize (s));
		}
예제 #34
0
 public WrapperIterator(XPathNodeIterator iter, NSResolver nsm)
     : base(nsm)
 {
     this.iter = iter;
 }
예제 #35
0
		internal override ValueType ParseValueType (string s, XmlNameTable nameTable, NSResolver nsmgr) 
		{
			return XmlConvert.ToDecimal (Normalize (s));
		}
예제 #36
0
 public SimpleIterator(XPathNavigator nav, NSResolver nsm) : base(nsm)
 {
     _nav = nav.Clone();
 }
예제 #37
0
		// if matchesAttr then check attributes; otherwise check elements.
		internal XsdIdentityPath Matches (bool matchesAttr, object sender, XmlNameTable nameTable, ArrayList qnameStack, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo lineInfo, int depth, string attrName, string attrNS, object attrValue)
		{
			XsdIdentityPath matchedAttrPath = null;

			for (int i = 0; i < field.Paths.Length; i++) {
				XsdIdentityPath path = field.Paths [i];
				bool isAttribute = path.IsAttribute;
				if (matchesAttr != isAttribute)
					continue;
				XsdIdentityStep step;
				if (path.IsAttribute) {
					step = path.OrderedSteps [path.OrderedSteps.Length - 1];
					bool match = false;
					if (step.IsAnyName || step.NsName != null) {
						if (step.IsAnyName || attrNS == step.NsName)
							match = true;
					}
					else if (step.Name == attrName && step.Namespace == attrNS)
						match = true;
					if (!match)
						continue;
					// first -1 is to reduce attr path step, next -1 is to reduce Attribute's depth in XmlReader.
					if (entry.StartDepth + (path.OrderedSteps.Length - 1) != depth - 1)
						continue; // matched at different nest level
					matchedAttrPath = path;
				}
				if (FieldFound && (depth > this.FieldFoundDepth && this.FieldFoundPath == path))
					continue; // don't return; other fields might hit errorneously.

				// Only "." hits.
				if (path.OrderedSteps.Length == 0) {
					if (depth == entry.StartDepth)
						return path;
					else
						continue;
				}
				// It does not hit as yet (too shallow to hit).
				if (depth - entry.StartDepth < path.OrderedSteps.Length - 1)
					continue;

				int iter = path.OrderedSteps.Length;
				if (isAttribute)
					iter--;
				if (path.Descendants && depth < entry.StartDepth + iter)
					continue;
				else if (!path.Descendants && depth != entry.StartDepth + iter)
					continue;

				iter--;

				for (; iter >= 0; iter--) {
					step = path.OrderedSteps [iter];
					if (step.IsCurrent || step.IsAnyName)
						continue;
					XmlQualifiedName qname = (XmlQualifiedName) qnameStack [entry.StartDepth + iter + (isAttribute ? 0 : 1)];
					if (step.NsName != null && qname.Namespace == step.NsName)
						continue;
					if ((step.Name == "*" || step.Name == qname.Name) &&
						step.Namespace == qname.Namespace)
						continue;
					else
						break;
				}
				if (iter >= 0)	// i.e. did not match against the path.
					continue;

				if (!matchesAttr)
					return path;
			}
			if (matchedAttrPath != null) {
				this.FillAttributeFieldValue (sender, nameTable, sourceUri, schemaType, nsResolver, attrValue, lineInfo, depth);
				if (this.Identity != null)
					return matchedAttrPath;
			}
			return null;
		}
예제 #38
0
 public ParentIterator(XPathNavigator nav, NSResolver nsm) : base(nav, nsm)
 {
 }
예제 #39
0
		// In this method, attributes are ignored.
		// It might throw Exception.
		public void ProcessMatch (bool isAttribute, ArrayList qnameStack, object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo li, int depth, string attrName, string attrNS, object attrValue, bool isXsiNil, ArrayList currentKeyFieldConsumers)
		{
			for (int i = 0; i < KeyFields.Count; i++) {
				XsdKeyEntryField keyField = KeyFields [i];
				XsdIdentityPath path = keyField.Matches (isAttribute, sender, nameTable, qnameStack, sourceUri, schemaType, nsResolver, li, depth, attrName, attrNS, attrValue);
				if (path == null)
					continue;

				if (keyField.FieldFound) {
					// HACK: This is not logical by nature. Attributes never be cosuming,
					// so I used it as a temporary mark to sign it is *just* validated now.
					if (!keyField.Consuming)
						throw new ValException ("Two or more matching field was found.",
							sender, sourceUri, this.OwnerSequence.SourceSchemaIdentity, null);
					else
						keyField.Consuming = false;
				}
				if (keyField.Consumed) 
					continue;

				if (isXsiNil && !keyField.SetIdentityField (Guid.Empty, true, XsdAnySimpleType.Instance, depth, li))
					throw new ValException ("Two or more identical field was found.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
				XmlSchemaComplexType ct = schemaType as XmlSchemaComplexType;
				if (ct != null && 
					(ct.ContentType == XmlSchemaContentType.Empty || ct.ContentType == XmlSchemaContentType.ElementOnly) && 
					schemaType != XmlSchemaComplexType.AnyType)
					throw new ValException ("Specified schema type is complex type, which is not allowed for identity constraints.", sender, sourceUri, OwnerSequence.SourceSchemaIdentity, null);
				keyField.FieldFound = true;
				keyField.FieldFoundPath = path;
				keyField.FieldFoundDepth = depth;
				keyField.Consuming = true;
				if (li != null && li.HasLineInfo ()) {
					keyField.FieldHasLineInfo = true;
					keyField.FieldLineNumber = li.LineNumber;
					keyField.FieldLinePosition = li.LinePosition;
				}
				currentKeyFieldConsumers.Add (keyField);
			}
		}
예제 #40
0
 internal BaseIterator(NSResolver nsm)
 {
     _nsm = nsm;
 }
		internal bool EvaluateBoolean (XPathExpression expr, XPathNodeIterator context, NSResolver ctx)
		{
			CompiledExpression cexpr = (CompiledExpression) expr;
			if (ctx == null)
				ctx = cexpr.NamespaceManager;
			
			if (context == null)
				context = new NullIterator (this, cexpr.NamespaceManager);
			BaseIterator iterContext = ToBaseIterator (context, ctx);
			iterContext.NamespaceManager = ctx;
			return cexpr.EvaluateBoolean (iterContext);
		}
예제 #42
0
		public void WriteCompact (TextWriter writer, NSResolver res)
		{
			WriteCompact (new RncWriter (writer, res));
		}
예제 #43
0
 public void WriteCompact(TextWriter writer, NSResolver res)
 {
     WriteCompact(new RncWriter(writer, res));
 }
예제 #44
0
파일: Iterator.cs 프로젝트: cyplo/mono
		public ListIterator (IList list, NSResolver nsm) : base (nsm)
		{
			_list = list;
		}
예제 #45
0
파일: Iterator.cs 프로젝트: cyplo/mono
		public WrapperIterator (XPathNodeIterator iter, NSResolver nsm)
			: base (nsm)
		{
			this.iter = iter;
		}
예제 #46
0
		private void FillAttributeFieldValue (object sender, XmlNameTable nameTable, string sourceUri, object schemaType, NSResolver nsResolver, object identity, IXmlLineInfo lineInfo, int depth)
		{
			if (this.FieldFound)
				throw new ValException (String.Format ("The key value was already found as '{0}'{1}.", Identity,
					(this.FieldHasLineInfo ?
						String.Format (CultureInfo.InvariantCulture, " at line {0}, position {1}", FieldLineNumber, FieldLinePosition) :
						"")),
					sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, null);
			XmlSchemaDatatype dt = schemaType as XmlSchemaDatatype;
			XmlSchemaSimpleType st = schemaType as XmlSchemaSimpleType;
			if (dt == null && st != null)
				dt = st.Datatype;
			try {
				if (!this.SetIdentityField (identity, false, dt as XsdAnySimpleType, depth, lineInfo))
					throw new ValException ("Two or more identical field was found.",
						sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, null);
				// HACK: This is not logical. Attributes will never be "cosuming",
				// so I used it as a temporary mark to sign it is validated *just now*.
				this.Consuming = true;
				this.FieldFound = true;
			} catch (Exception ex) {
				throw new ValException ("Failed to read typed value.", sender, sourceUri, entry.OwnerSequence.SourceSchemaIdentity, ex);
			}
		}
예제 #47
0
파일: Iterator.cs 프로젝트: cyplo/mono
		public SimpleIterator (XPathNavigator nav, NSResolver nsm) : base (nsm)
		{
			_nav = nav.Clone ();
		}
		BaseIterator ToBaseIterator (XPathNodeIterator iter, NSResolver ctx)
		{
			BaseIterator i = iter as BaseIterator;
			if (i == null)
				i = new WrapperIterator (iter, ctx);
			return i;
		}
예제 #49
0
파일: Iterator.cs 프로젝트: cyplo/mono
		public NullIterator (XPathNavigator nav, NSResolver nsm) : base (nav, nsm) {}
		internal XPathNodeIterator Select (XPathExpression expr, NSResolver ctx)
		{
			CompiledExpression cexpr = (CompiledExpression) expr;
			if (ctx == null)
				ctx = cexpr.NamespaceManager;
			
			BaseIterator iter = new NullIterator (this, ctx);
			return cexpr.EvaluateNodeSet (iter);
		}
예제 #51
0
        // if matchesAttr then check attributes; otherwise check elements.
        internal XsdIdentityPath Matches(bool matchesAttr, object sender, XmlNameTable nameTable, ArrayList qnameStack, string sourceUri, object schemaType, NSResolver nsResolver, IXmlLineInfo lineInfo, int depth, string attrName, string attrNS, object attrValue)
        {
            XsdIdentityPath matchedAttrPath = null;

            for (int i = 0; i < field.Paths.Length; i++)
            {
                XsdIdentityPath path        = field.Paths [i];
                bool            isAttribute = path.IsAttribute;
                if (matchesAttr != isAttribute)
                {
                    continue;
                }
                XsdIdentityStep step;
                if (path.IsAttribute)
                {
                    step = path.OrderedSteps [path.OrderedSteps.Length - 1];
                    bool match = false;
                    if (step.IsAnyName || step.NsName != null)
                    {
                        if (step.IsAnyName || attrNS == step.NsName)
                        {
                            match = true;
                        }
                    }
                    else if (step.Name == attrName && step.Namespace == attrNS)
                    {
                        match = true;
                    }
                    if (!match)
                    {
                        continue;
                    }
                    // first -1 is to reduce attr path step, next -1 is to reduce Attribute's depth in XmlReader.
                    if (entry.StartDepth + (path.OrderedSteps.Length - 1) != depth - 1)
                    {
                        continue;                         // matched at different nest level
                    }
                    matchedAttrPath = path;
                }
                if (FieldFound && (depth > this.FieldFoundDepth && this.FieldFoundPath == path))
                {
                    continue;                     // don't return; other fields might hit errorneously.
                }
                // Only "." hits.
                if (path.OrderedSteps.Length == 0)
                {
                    if (depth == entry.StartDepth)
                    {
                        return(path);
                    }
                    else
                    {
                        continue;
                    }
                }
                // It does not hit as yet (too shallow to hit).
                if (depth - entry.StartDepth < path.OrderedSteps.Length - 1)
                {
                    continue;
                }

                int iter = path.OrderedSteps.Length;
                if (isAttribute)
                {
                    iter--;
                }
                if (path.Descendants && depth < entry.StartDepth + iter)
                {
                    continue;
                }
                else if (!path.Descendants && depth != entry.StartDepth + iter)
                {
                    continue;
                }

                iter--;

                for (; iter >= 0; iter--)
                {
                    step = path.OrderedSteps [iter];
                    if (step.IsCurrent || step.IsAnyName)
                    {
                        continue;
                    }
                    XmlQualifiedName qname = (XmlQualifiedName)qnameStack [entry.StartDepth + iter + (isAttribute ? 0 : 1)];
                    if (step.NsName != null && qname.Namespace == step.NsName)
                    {
                        continue;
                    }
                    if ((step.Name == "*" || step.Name == qname.Name) &&
                        step.Namespace == qname.Namespace)
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
                if (iter >= 0)                  // i.e. did not match against the path.
                {
                    continue;
                }

                if (!matchesAttr)
                {
                    return(path);
                }
            }
            if (matchedAttrPath != null)
            {
                this.FillAttributeFieldValue(sender, nameTable, sourceUri, schemaType, nsResolver, attrValue, lineInfo, depth);
                if (this.Identity != null)
                {
                    return(matchedAttrPath);
                }
            }
            return(null);
        }