Ejemplo n.º 1
0
      protected virtual Exception CreateParseException(IXmlLineInfo lineInfo, string format, params object[] args) {

         if (lineInfo != null && lineInfo.HasLineInfo())
            return new HttpParseException(String.Format(CultureInfo.InvariantCulture, format, args), null, this.VirtualPath, null, lineInfo.LineNumber);
         else
            return new HttpParseException(String.Format(CultureInfo.InvariantCulture, format, args));
      }
 private void SetLineInfo(IXmlLineInfo lineInfo, SearchResult searchResult)
 {
     if(lineInfo.HasLineInfo())
     {
         searchResult.LineNumber = lineInfo.LineNumber;
         searchResult.LinePosition = lineInfo.LinePosition;
     }
 }
Ejemplo n.º 3
0
        public Attribute(string name, IXmlLineInfo lineInfo)
        {
            this.name = name;

            _hasLineInfo = lineInfo.HasLineInfo();
            _lineNumber = lineInfo.LineNumber;
            _linePosition = lineInfo.LinePosition;
        }
Ejemplo n.º 4
0
        static string AppendLineInfo(string message, IXmlLineInfo lineInfo)
        {
            if (lineInfo?.HasLineInfo() == true)
            {
                return($"{message} [{lineInfo.LineNumber}:{lineInfo.LinePosition}]");
            }

            return(message);
        }
Ejemplo n.º 5
0
		static string BuildMessage (string message, IXmlLineInfo li, string sourceUri)
		{
			if (li != null && li.HasLineInfo ()) {
				message = String.Format ("{0}. Location: {1} ({2}, {3}).", message, sourceUri, li.LineNumber, li.LinePosition);
			}
			else if (sourceUri != null)
				message = String.Format ("{0}. Location: {1}", message, sourceUri);
			return message;
		}
Ejemplo n.º 6
0
 protected internal ParseErrorEventArgs(string message, IXmlLineInfo lineInfo)
 {
     this._message = message;
     if (lineInfo != null) {
         this._hasLineInfo = lineInfo.HasLineInfo();
         this._lineNumber = lineInfo.LineNumber;
         this._linePosition = lineInfo.LinePosition;
     }
 }
 private bool GetLineNumber(XDocument xdoc, string location, out IXmlLineInfo info)
 {
     info = null;
     try
     {
         XElement find = xdoc.XPathSelectElement(location);
         info = find as IXmlLineInfo;
     }
     catch { }
     return(info?.HasLineInfo() ?? false);
 }
 private bool GetLineNumberBySaxon(ProcessorEvaluation evaluation, string location, out IXmlLineInfo info)
 {
     info = null;
     try
     {
         XmlNode node = evaluation.SelectNode(location);
         if (node == null)
         {
             throw new Exception();
         }
         string   findAt = FindAtPath(node.CreateNavigator());
         XElement find   = evaluation.XPathSelectElement(findAt);
         info = find as IXmlLineInfo;
     }
     catch { }
     return(info?.HasLineInfo() ?? false);
 }
Ejemplo n.º 9
0
		internal static string FormatMessage (string message,
			IXmlLineInfo lineInfo)
		{
			NvdlElementBase source = lineInfo as NvdlElementBase;
			XmlReader reader = lineInfo as XmlReader;
			if (source != null && source.HasLineInfo ())
				return String.Format ("{0}. {1} ({2},{3})",
					message, source.SourceUri,
					source.LineNumber, source.LinePosition);
			else if (lineInfo != null && lineInfo.HasLineInfo ())
				return String.Format ("{0}. {3}({1},{2})",
					message,
					lineInfo.LineNumber,
					lineInfo.LinePosition,
					reader != null ? reader.BaseURI + ' ' : String.Empty);
			else
				return message;
		}
Ejemplo n.º 10
0
        /// <summary>
        /// Read an XNode from the given XmlReader and LineInfo object. If available, line info will be added to XElement.
        /// This technique is adapted from here: http://blogs.msdn.com/b/mikechampion/archive/2006/09/10/748408.aspx
        /// </summary>
        /// <param name="reader">The XmlReader to read from</param>
        /// <param name="lineInfo">This should be <paramref name="reader"/> cast as an <see cref="IXmlLineInfo"/></param>
        /// <returns>an XNode with line information if present</returns>
        /// <seealso cref="XNode.ReadFrom">This function replaces XNode.ReadFrom</seealso>
        public static XNode ReadWithLineInfo(XmlReader reader, IXmlLineInfo lineInfo)
        {
            XNode node = null;
            XElement parent = null;

            do
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        // create a new element with the given name
                        XElement element = new XElement(XName.Get(reader.LocalName, reader.NamespaceURI));

                        // add attributes to the element
                        if (reader.MoveToFirstAttribute())
                        {
                            do
                            {
                                // Compound documents created with older versions of ABB.SrcML left out some namespaces
                                // this causes an "xmlns" attribute to be added to any names not in the default (SRC) namespace
                                // to avoid an ArgumentException thrown by element.Add in this case, just don't add these
                                if (!(reader.LocalName == "xmlns" && reader.NamespaceURI == "http://www.w3.org/2000/xmlns/"))
                                    element.Add(new XAttribute(XName.Get(reader.LocalName, reader.NamespaceURI), reader.Value));
                            } while (reader.MoveToNextAttribute());
                            reader.MoveToElement();
                        }
                        // add a ABB.SrcML.LineInfo annotation to the element if line information is present.
                        if (lineInfo.HasLineInfo())
                        {
                            element.SetLineInfo(new LineInfo(lineInfo.LineNumber, lineInfo.LinePosition));
                        }

                        // if the reader is not empty, we have to go and get all of the children and add them.
                        // otherwise, we can jsut set this to node.
                        if (!reader.IsEmptyElement)
                        {
                            if (null != parent)
                            {
                                parent.Add(element);
                            }
                            parent = element;
                            continue;
                        }
                        else
                        {
                            node = element;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        // process the EndElement
                        if (null == parent)
                            return null;
                        if (parent.IsEmpty)
                        {
                            parent.Add(string.Empty);
                        }
                        if (parent.Parent == null)
                            return parent;
                        parent = parent.Parent;
                        continue;
                    case XmlNodeType.Text:
                    case XmlNodeType.SignificantWhitespace:
                    case XmlNodeType.Whitespace:
                        node = new XText(reader.Value);
                        break;
                    case XmlNodeType.CDATA:
                        node = new XCData(reader.Value);
                        break;
                    case XmlNodeType.Comment:
                        node = new XComment(reader.Value);
                        break;
                    case XmlNodeType.ProcessingInstruction:
                        node = new XProcessingInstruction(reader.Name, reader.Value);
                        break;
                    case XmlNodeType.DocumentType:
                        node = new XDocumentType(reader.LocalName, reader.GetAttribute("PUBLIC"), reader.GetAttribute("SYSTEM"), reader.Value);
                        break;
                    case XmlNodeType.EntityReference:
                        reader.ResolveEntity();
                        continue;
                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.EndEntity:
                        continue;
                    default:
                        throw new InvalidOperationException();
                }

                if (null == parent)
                    return node;
                parent.Add(node);
            } while (reader.Read());
            return null;
        }
Ejemplo n.º 11
0
 bool IXmlLineInfo.HasLineInfo()
 {
     return(readerLineInfo != null && readerLineInfo.HasLineInfo());
 }
 void Proceed(IXmlLineInfo li)
 {
     if (li == null || !li.HasLineInfo ())
         return;
     tw.ProceedTo (li.LineNumber, li.LinePosition);
 }
Ejemplo n.º 13
0
		public XamlXmlNodeInfo (XamlNodeType nodeType, object nodeValue, IXmlLineInfo lineInfo)
		{
			NodeType = nodeType;
			NodeValue = nodeValue;
			if (lineInfo != null && lineInfo.HasLineInfo ()) {
				HasLineInfo = true;
				LineNumber = lineInfo.LineNumber;
				LinePosition = lineInfo.LinePosition;
			} else {
				HasLineInfo = false;
				LineNumber = 0;
				LinePosition = 0;
			}
		}
Ejemplo n.º 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);
			}
		}
Ejemplo n.º 15
0
 public virtual bool HasLineInfo()
 {
     return(_readerAsIXmlLineInfo.HasLineInfo());
 }
Ejemplo n.º 16
0
 public bool HasLineInfo() => _baseLineInfo?.HasLineInfo() ?? false;
Ejemplo n.º 17
0
 public bool HasLineInfo() => _xmlLineInfo?.HasLineInfo() ?? false;
Ejemplo n.º 18
0
        /// <summary>Gets a value indicating whether the class can return line information.</summary>
        /// <returns>true if the class can return line information; otherwise, false.</returns>
        public bool HasLineInfo()
        {
            IXmlLineInfo xmlLineInfo = this.validatingReader as IXmlLineInfo;

            return(xmlLineInfo != null && xmlLineInfo.HasLineInfo());
        }
Ejemplo n.º 19
0
        // IXmlLineInfo members
        bool IXmlLineInfo.HasLineInfo()
        {
            IXmlLineInfo xmlLineInfo = InnerReader as IXmlLineInfo;

            return((xmlLineInfo == null) ? xmlReader.HasLineInfo() : xmlLineInfo.HasLineInfo());
        }
Ejemplo n.º 20
0
        public bool HasLineInfo()
        {
            IXmlLineInfo li = Current as IXmlLineInfo;

            return(li == null ? false : li.HasLineInfo());
        }
Ejemplo n.º 21
0
 public bool HasLineInfo()
 {
     return(lineInfo != null?lineInfo.HasLineInfo() : false);
 }
        // IXmlLineInfo members
        bool IXmlLineInfo.HasLineInfo()
        {
            IXmlLineInfo iXmlLineInfo = innerReader as IXmlLineInfo;

            return((iXmlLineInfo == null) ? false : iXmlLineInfo.HasLineInfo());
        }
Ejemplo n.º 23
0
        public GrepSearchResult.GrepMatch[] getFilePositions(string text, List <XPathPosition> positions)
        {
            bool[] endFound = new bool[positions.Count];
            // Getting line lengths
            List <int> lineLengths = new List <int>();

            using (StringReader baseReader = new StringReader(text))
            {
                using (EolReader reader = new EolReader(baseReader))
                {
                    while (!reader.EndOfStream)
                    {
                        lineLengths.Add(reader.ReadLine().Length);
                    }
                }
            }
            // These are absolute positions
            GrepSearchResult.GrepMatch[] results = new GrepSearchResult.GrepMatch[positions.Count];
            if (positions.Count == 0)
            {
                return(results);
            }

            using (StringReader textReader = new StringReader(text))
                using (XmlReader reader = XmlReader.Create(textReader))
                {
                    List <int> currPos = new List <int>();

                    try
                    {
                        IXmlLineInfo lineInfo = ((IXmlLineInfo)reader);
                        if (lineInfo.HasLineInfo())
                        {
                            bool readyToBreak = false;
                            // Parse the XML and display each node.
                            while (reader.Read() && !readyToBreak)
                            {
                                switch (reader.NodeType)
                                {
                                case XmlNodeType.Element:

                                    if (currPos.Count <= reader.Depth)
                                    {
                                        currPos.Add(1);
                                    }
                                    else
                                    {
                                        currPos[reader.Depth]++;
                                    }

                                    break;

                                case XmlNodeType.EndElement:
                                    while (reader.Depth < currPos.Count - 1)
                                    {
                                        currPos.RemoveAt(reader.Depth + 1); // currPos.Count - 1 would work too.
                                    }

                                    for (int i = 0; i < positions.Count; i++)
                                    {
                                        if (xPathPositionsMatch(currPos, positions[i].Path))
                                        {
                                            endFound[i] = true;
                                        }
                                    }
                                    break;

                                default:
                                    break;
                                }

                                if (reader.NodeType == XmlNodeType.EndElement)
                                {
                                    for (int i = 0; i < positions.Count; i++)
                                    {
                                        if (endFound[i] && !xPathPositionsMatch(currPos, positions[i].Path))
                                        {
                                            if (results[i] != null)
                                            {
                                                results[i].EndPosition = getAbsoluteCharPosition(lineInfo.LineNumber - 1, lineInfo.LinePosition - 3, text, lineLengths, true) + 1;
                                            }
                                            endFound[i] = false;
                                        }
                                    }
                                }

                                if (reader.NodeType == XmlNodeType.Element)
                                {
                                    for (int i = 0; i < positions.Count; i++)
                                    {
                                        if (endFound[i])
                                        {
                                            if (results[i] != null)
                                            {
                                                results[i].EndPosition = getAbsoluteCharPosition(lineInfo.LineNumber - 1, lineInfo.LinePosition - 3, text, lineLengths, true) + 1;
                                            }
                                            endFound[i] = false;
                                        }

                                        if (xPathPositionsMatch(currPos, positions[i].Path))
                                        {
                                            results[i] = new GrepSearchResult.GrepMatch(lineInfo.LineNumber - 1, getAbsoluteCharPosition(lineInfo.LineNumber - 1, lineInfo.LinePosition - 2, text, lineLengths, false), 0);
                                        }

                                        // If empty element (e.g.<element/>)
                                        if (reader.IsEmptyElement)
                                        {
                                            if (xPathPositionsMatch(currPos, positions[i].Path))
                                            {
                                                endFound[i] = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        for (int i = 0; i < positions.Count; i++)
                        {
                            if (results[i] != null && results[i].Length == 0)
                            {
                                results[i].EndPosition = text.Length - 1;
                            }
                        }

                        reader.Close();
                    }
                    // Close the reader.
                }
            return(results);
        }
Ejemplo n.º 24
0
//
// IXmlLineInfo members
//
        public virtual bool HasLineInfo()
        {
            return((_readerAsIXmlLineInfo == null) ? false : _readerAsIXmlLineInfo.HasLineInfo());
        }
Ejemplo n.º 25
0
		static string FormatMessage(string message, IXmlLineInfo xmlinfo)
		{
			if (xmlinfo == null || !xmlinfo.HasLineInfo())
				return message;
			return string.Format("Position {0}:{1}. {2}", xmlinfo.LineNumber, xmlinfo.LinePosition, message);
		}
Ejemplo n.º 26
0
 /// <summary>
 /// Takes one of the xml line number so the numbers are now zero
 /// based instead of one based.
 /// </summary>
 /// <remarks>A namespace query (e.g. //namespace::*) will return
 /// a line info of -1, -1 for the xml namespace. Which looks like
 /// a bug in the XPathDocument class.</remarks>
 void SetLineNumbers(IXmlLineInfo lineInfo)
 {
     if (lineInfo.HasLineInfo() && lineInfo.LineNumber > 0) {
         lineNumber = lineInfo.LineNumber - 1;
         linePosition = lineInfo.LinePosition - 1;
     }
 }
Ejemplo n.º 27
0
        internal void ReadContentFrom(XmlReader r, LoadOptions o)
        {
            if ((o & (LoadOptions.SetBaseUri | LoadOptions.SetLineInfo)) == 0)
            {
                ReadContentFrom(r);
                return;
            }
            if (r.ReadState != ReadState.Interactive)
            {
                throw new InvalidOperationException(SR.InvalidOperation_ExpectedInteractive);
            }
            XContainer     c       = this;
            XNode          n       = null;
            NamespaceCache eCache  = new NamespaceCache();
            NamespaceCache aCache  = new NamespaceCache();
            string         baseUri = (o & LoadOptions.SetBaseUri) != 0 ? r.BaseURI : null;
            IXmlLineInfo   li      = (o & LoadOptions.SetLineInfo) != 0 ? r as IXmlLineInfo : null;

            do
            {
                string uri = r.BaseURI;
                switch (r.NodeType)
                {
                case XmlNodeType.Element:
                {
                    XElement e = new XElement(eCache.Get(r.NamespaceURI).GetName(r.LocalName));
                    if (baseUri != null && baseUri != uri)
                    {
                        e.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        e.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (r.MoveToFirstAttribute())
                    {
                        do
                        {
                            XAttribute a = new XAttribute(aCache.Get(r.Prefix.Length == 0 ? string.Empty : r.NamespaceURI).GetName(r.LocalName), r.Value);
                            if (li != null && li.HasLineInfo())
                            {
                                a.SetLineInfo(li.LineNumber, li.LinePosition);
                            }
                            e.AppendAttributeSkipNotify(a);
                        } while (r.MoveToNextAttribute());
                        r.MoveToElement();
                    }
                    c.AddNodeSkipNotify(e);
                    if (!r.IsEmptyElement)
                    {
                        c = e;
                        if (baseUri != null)
                        {
                            baseUri = uri;
                        }
                    }
                    break;
                }

                case XmlNodeType.EndElement:
                {
                    if (c.content == null)
                    {
                        c.content = string.Empty;
                    }
                    // Store the line info of the end element tag.
                    // Note that since we've got EndElement the current container must be an XElement
                    XElement e = c as XElement;
                    Debug.Assert(e != null, "EndElement received but the current container is not an element.");
                    if (e != null && li != null && li.HasLineInfo())
                    {
                        e.SetEndElementLineInfo(li.LineNumber, li.LinePosition);
                    }
                    if (c == this)
                    {
                        return;
                    }
                    if (baseUri != null && c.HasBaseUri)
                    {
                        baseUri = c.parent.BaseUri;
                    }
                    c = c.parent;
                    break;
                }

                case XmlNodeType.Text:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.Whitespace:
                    if ((baseUri != null && baseUri != uri) ||
                        (li != null && li.HasLineInfo()))
                    {
                        n = new XText(r.Value);
                    }
                    else
                    {
                        c.AddStringSkipNotify(r.Value);
                    }
                    break;

                case XmlNodeType.CDATA:
                    n = new XCData(r.Value);
                    break;

                case XmlNodeType.Comment:
                    n = new XComment(r.Value);
                    break;

                case XmlNodeType.ProcessingInstruction:
                    n = new XProcessingInstruction(r.Name, r.Value);
                    break;

                case XmlNodeType.DocumentType:
                    n = new XDocumentType(r.LocalName, r.GetAttribute("PUBLIC"), r.GetAttribute("SYSTEM"), r.Value);
                    break;

                case XmlNodeType.EntityReference:
                    if (!r.CanResolveEntity)
                    {
                        throw new InvalidOperationException(SR.InvalidOperation_UnresolvedEntityReference);
                    }
                    r.ResolveEntity();
                    break;

                case XmlNodeType.EndEntity:
                    break;

                default:
                    throw new InvalidOperationException(SR.Format(SR.InvalidOperation_UnexpectedNodeType, r.NodeType));
                }
                if (n != null)
                {
                    if (baseUri != null && baseUri != uri)
                    {
                        n.SetBaseUri(uri);
                    }
                    if (li != null && li.HasLineInfo())
                    {
                        n.SetLineInfo(li.LineNumber, li.LinePosition);
                    }
                    c.AddNodeSkipNotify(n);
                    n = null;
                }
            } while (r.Read());
        }
Ejemplo n.º 28
0
 private void VerifyLineInfo(IXmlLineInfo l1, IXmlLineInfo l2, string uri)
 {
     TestLog.Equals(l1.HasLineInfo(), l2.HasLineInfo(), "HasLineInfo ::: " + uri);
     TestLog.Equals(l1.LineNumber, l2.LineNumber, "LineNumber ::: " + uri);
     TestLog.Equals(l1.LinePosition, l2.LinePosition, "LinePosition ::: " + uri);
 }
Ejemplo n.º 29
0
 public override bool HasLineInfo()
 {
     return(_lineInfo.HasLineInfo());
 }
Ejemplo n.º 30
0
 internal LineInfo(IXmlLineInfo lineInfo)
 {
     m_hasLineInfo = lineInfo.HasLineInfo();
     m_lineNumber = lineInfo.LineNumber;
     m_linePosition = lineInfo.LinePosition;
 }
Ejemplo n.º 31
0
        public ResultCollection Validation(string xmlfile)
        {
            ResultCollection    results    = new ResultCollection();
            XmlDocument         doc        = null;
            XDocument           xdoc       = null;
            ProcessorEvaluation evaluation = null;

            try
            {
                xdoc = XDocument.Load(xmlfile, LoadOptions.SetLineInfo);

                doc = _processor.Validation(xmlfile);

                if (IsDebug)
                {
                    File.WriteAllText(Path.ChangeExtension(xmlfile, ".report.xml"), doc.OuterXml, Encoding.UTF8);
                }
                XmlNodeList nodes = doc.SelectNodes("//*[local-name()='failed-assert' or local-name()='successful-report']");
                if (nodes != null)
                {
                    foreach (XmlNode node in nodes)
                    {
                        Result result = new Result();
                        result.SchFile = SchemaSrc;
                        result.XmlFile = new FileInfo(xmlfile);

                        result.Status    = node.LocalName == "failed-assert" ? ResultStatus.Assert : ResultStatus.Report;
                        result.Test      = node.Attributes["test"]?.Value ?? "";
                        result.Location  = node.Attributes["location"]?.Value ?? "";
                        result.Role.Name = node.Attributes["role"]?.Value ?? "";

                        IXmlLineInfo lineinfo = null;
                        if (!GetLineNumber(xdoc, result.Location, out lineinfo))
                        {
                            if (evaluation == null)
                            {
                                evaluation = new ProcessorEvaluation(xdoc);
                                evaluation.Compile(_processor.Processor);
                            }
                            GetLineNumberBySaxon(evaluation, result.Location, out lineinfo);
                        }
                        if (lineinfo?.HasLineInfo() ?? false)
                        {
                            result.Line = lineinfo.LineNumber;
                            result.Pos  = lineinfo.LinePosition;
                        }

                        StringBuilder sb    = new StringBuilder();
                        XmlNodeList   texts = node.SelectNodes(".//*[local-name()='text']");
                        if (texts != null)
                        {
                            foreach (XmlNode text in texts)
                            {
                                sb.AppendLine(text.InnerXml);
                            }
                        }
                        result.Message = sb.Length > 0 ? sb.ToString() : node.InnerXml;

                        results.Add(result);
                    }
                }
            }
            catch (XmlException ex)
            {
                results.Add(new Result()
                {
                    SchFile = SchemaSrc,
                    XmlFile = new FileInfo(xmlfile),
                    Status  = ResultStatus.SyntaxError,
                    Message = ex.Message,
                    Line    = ex.LineNumber,
                    Pos     = ex.LinePosition,
                });
            }
            catch (Exception ex)
            {
                results.Add(new Result()
                {
                    SchFile = SchemaSrc,
                    XmlFile = new FileInfo(xmlfile),
                    Status  = ResultStatus.SyntaxError,
                    Message = ex.Message
                });
            }
            results.TrimExcess();
            return(results);
        }
Ejemplo n.º 32
0
		private void Init (XsdKeyTable keyseq, int depth, IXmlLineInfo li)
		{
			OwnerSequence = keyseq;
			KeyFields = new XsdKeyEntryFieldCollection ();
			for (int i = 0; i < keyseq.Selector.Fields.Length; i++)
				KeyFields.Add (new XsdKeyEntryField (this, keyseq.Selector.Fields [i]));
			StartDepth = depth;
			if (li != null) {
				if (li.HasLineInfo ()) {
					this.SelectorHasLineInfo = true;
					this.SelectorLineNumber = li.LineNumber;
					this.SelectorLinePosition = li.LinePosition;
				}
			}
		}
Ejemplo n.º 33
0
                                                                                                  // IXmlLineInfo members
                                                                                                  internal bool HasLineInfo()
        {
            IXmlLineInfo iXmlLineInfo = reader as IXmlLineInfo;

            return((iXmlLineInfo == null) ? false : iXmlLineInfo.HasLineInfo());
        }
Ejemplo n.º 34
0
		// Return false if there is already the same key.
		public bool SetIdentityField (object identity, bool isXsiNil, XsdAnySimpleType type, int depth, IXmlLineInfo li)
		{
			FieldFoundDepth = depth;
			Identity = identity;
			IsXsiNil = isXsiNil;
			FieldFound |= isXsiNil;
			FieldType = type;
			Consuming = false;
			Consumed = true;
			if (li != null && li.HasLineInfo ()) {
				FieldHasLineInfo = true;
				FieldLineNumber = li.LineNumber;
				FieldLinePosition = li.LinePosition;
			}

			if (!(this.entry.OwnerSequence.SourceSchemaIdentity is XmlSchemaKeyref)) {
				for (int i = 0; i < entry.OwnerSequence.FinishedEntries.Count; i++) {
					XsdKeyEntry other = (XsdKeyEntry) entry.OwnerSequence.FinishedEntries [i];
					if (this.entry.CompareIdentity (other))
						return false;
				}
			}

			return true;
		}
Ejemplo n.º 35
0
        public void TestLineInfo()
        {
            XIncludingReader r        = new XIncludingReader("../../XInclude/tests/document.xml");
            IXmlLineInfo     lineInfo = ((IXmlLineInfo)r);

            Assert.IsTrue(lineInfo.HasLineInfo());
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(22, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(2, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(54, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(6, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(8, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(54, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(56, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(1, lineInfo.LineNumber);
            Assert.AreEqual(22, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(5, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(2, lineInfo.LineNumber);
            Assert.AreEqual(17, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(3, lineInfo.LineNumber);
            Assert.AreEqual(12, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(2, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(13, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(5, lineInfo.LineNumber);
            Assert.AreEqual(4, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(5, lineInfo.LineNumber);
            Assert.AreEqual(6, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(7, lineInfo.LineNumber);
            Assert.AreEqual(18, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(7, lineInfo.LineNumber);
            Assert.AreEqual(20, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(8, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(4, lineInfo.LineNumber);
            Assert.AreEqual(75, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(6, lineInfo.LineNumber);
            Assert.AreEqual(3, lineInfo.LinePosition);
            r.Read();
            Assert.AreEqual(6, lineInfo.LineNumber);
            Assert.AreEqual(12, lineInfo.LinePosition);
        }