コード例 #1
0
ファイル: BaseParser.cs プロジェクト: nuxleus/Nuxleus
      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));
      }
コード例 #2
0
 private void SetLineInfo(IXmlLineInfo lineInfo, SearchResult searchResult)
 {
     if(lineInfo.HasLineInfo())
     {
         searchResult.LineNumber = lineInfo.LineNumber;
         searchResult.LinePosition = lineInfo.LinePosition;
     }
 }
コード例 #3
0
ファイル: Attribute.cs プロジェクト: datanowllc/twintsam
        public Attribute(string name, IXmlLineInfo lineInfo)
        {
            this.name = name;

            _hasLineInfo = lineInfo.HasLineInfo();
            _lineNumber = lineInfo.LineNumber;
            _linePosition = lineInfo.LinePosition;
        }
コード例 #4
0
        static string AppendLineInfo(string message, IXmlLineInfo lineInfo)
        {
            if (lineInfo?.HasLineInfo() == true)
            {
                return($"{message} [{lineInfo.LineNumber}:{lineInfo.LinePosition}]");
            }

            return(message);
        }
コード例 #5
0
ファイル: XmlQueryException.cs プロジェクト: Profit0004/mono
		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;
		}
コード例 #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;
     }
 }
コード例 #7
0
 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);
 }
コード例 #8
0
 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);
 }
コード例 #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;
		}
コード例 #10
0
ファイル: XmlHelper.cs プロジェクト: akondrahman/SrcML.NET
        /// <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;
        }
コード例 #11
0
 bool IXmlLineInfo.HasLineInfo()
 {
     return(readerLineInfo != null && readerLineInfo.HasLineInfo());
 }
コード例 #12
0
 void Proceed(IXmlLineInfo li)
 {
     if (li == null || !li.HasLineInfo ())
         return;
     tw.ProceedTo (li.LineNumber, li.LinePosition);
 }
コード例 #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;
			}
		}
コード例 #14
0
ファイル: XsdIdentityState.cs プロジェクト: nobled/mono
		// 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
 public virtual bool HasLineInfo()
 {
     return(_readerAsIXmlLineInfo.HasLineInfo());
 }
コード例 #16
0
 public bool HasLineInfo() => _baseLineInfo?.HasLineInfo() ?? false;
コード例 #17
0
ファイル: XmlDirector.cs プロジェクト: TSSArt/Xtate.Core
 public bool HasLineInfo() => _xmlLineInfo?.HasLineInfo() ?? false;
コード例 #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());
        }
コード例 #19
0
        // IXmlLineInfo members
        bool IXmlLineInfo.HasLineInfo()
        {
            IXmlLineInfo xmlLineInfo = InnerReader as IXmlLineInfo;

            return((xmlLineInfo == null) ? xmlReader.HasLineInfo() : xmlLineInfo.HasLineInfo());
        }
コード例 #20
0
        public bool HasLineInfo()
        {
            IXmlLineInfo li = Current as IXmlLineInfo;

            return(li == null ? false : li.HasLineInfo());
        }
コード例 #21
0
ファイル: XmlFilterReader.cs プロジェクト: pmq20/mono_forked
 public bool HasLineInfo()
 {
     return(lineInfo != null?lineInfo.HasLineInfo() : false);
 }
コード例 #22
0
        // IXmlLineInfo members
        bool IXmlLineInfo.HasLineInfo()
        {
            IXmlLineInfo iXmlLineInfo = innerReader as IXmlLineInfo;

            return((iXmlLineInfo == null) ? false : iXmlLineInfo.HasLineInfo());
        }
コード例 #23
0
ファイル: GrepEngineBase.cs プロジェクト: wqssyq/dnGrep
        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);
        }
コード例 #24
0
ファイル: XmlWrappingReader.cs プロジェクト: ash2005/z
//
// IXmlLineInfo members
//
        public virtual bool HasLineInfo()
        {
            return((_readerAsIXmlLineInfo == null) ? false : _readerAsIXmlLineInfo.HasLineInfo());
        }
コード例 #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);
		}
コード例 #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;
     }
 }
コード例 #27
0
ファイル: XContainer.cs プロジェクト: must/dotnet-corefx
        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());
        }
コード例 #28
0
ファイル: IXmlLineInfo.cs プロジェクト: johnhhm/corefx
 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);
 }
コード例 #29
0
ファイル: IXmlLineInfo.cs プロジェクト: aik-jahoda/runtime
 public override bool HasLineInfo()
 {
     return(_lineInfo.HasLineInfo());
 }
コード例 #30
0
ファイル: LineInfo.cs プロジェクト: Cireson/EntityFramework6
 internal LineInfo(IXmlLineInfo lineInfo)
 {
     m_hasLineInfo = lineInfo.HasLineInfo();
     m_lineNumber = lineInfo.LineNumber;
     m_linePosition = lineInfo.LinePosition;
 }
コード例 #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);
        }
コード例 #32
0
ファイル: XsdIdentityState.cs プロジェクト: nobled/mono
		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;
				}
			}
		}
コード例 #33
0
                                                                                                  // IXmlLineInfo members
                                                                                                  internal bool HasLineInfo()
        {
            IXmlLineInfo iXmlLineInfo = reader as IXmlLineInfo;

            return((iXmlLineInfo == null) ? false : iXmlLineInfo.HasLineInfo());
        }
コード例 #34
0
ファイル: XsdIdentityState.cs プロジェクト: nobled/mono
		// 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;
		}
コード例 #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);
        }