Inheritance: IErrorHelper
 public void AddNamespace(XsltInput input)
 {
     if (Ref.Equal(input.LocalName, input.Atoms.Xml))
     {
         Debug.Assert(input.Value == XmlReservedNs.NsXml, "XmlReader must check binding for 'xml' prefix");
     }
     else
     {
         nsList = new NsDecl(nsList, input.LocalName, input.Value);
     }
 }
            public void SaveExtendedLineInfo(XsltInput input)
            {
                elemNameLi = new SourceLineInfo(
                    lineInfo.Uri,
                    lineInfo.StartLine, lineInfo.StartPos + 1,  // "<"
                    lineInfo.StartLine, lineInfo.StartPos + 1 + elemNameLength
                    );

                if (!input.IsEmptyElement)
                {
                    Debug.Assert(input.reader.NodeType == XmlNodeType.EndElement);
                    endTagLi = input.BuildLineInfo();
                }
                else
                {
                    Debug.Assert(input.reader.NodeType == XmlNodeType.Element);
                    endTagLi = new EmptyElementEndTag(lineInfo);
                }
            }
Example #3
0
        private Stylesheet LoadStylesheet(XmlReader reader, bool include)
        {
            string baseUri = reader.BaseURI;
            Debug.Assert(!_documentUriInUse.Contains(baseUri), "Circular references must be checked while processing xsl:include and xsl:import");
            _documentUriInUse.Add(baseUri, null);
            _compiler.AddModule(baseUri);

            Stylesheet prevStylesheet = _curStylesheet;
            XsltInput prevInput = _input;
            Stylesheet thisStylesheet = include ? _curStylesheet : _compiler.CreateStylesheet();

            _input = new XsltInput(reader, _compiler, _atoms);
            _curStylesheet = thisStylesheet;

            try
            {
                LoadDocument();
                if (!include)
                {
                    _compiler.MergeWithStylesheet(_curStylesheet);

                    List<Uri> importHrefs = _curStylesheet.ImportHrefs;
                    _curStylesheet.Imports = new Stylesheet[importHrefs.Count];
                    // Imports should be compiled in the reverse order. Template lookup logic relies on that.
                    for (int i = importHrefs.Count; 0 <= --i;)
                    {
                        _curStylesheet.Imports[i] = LoadStylesheet(importHrefs[i], /*include:*/false);
                    }
                }
            }
            catch (XslLoadException)
            {
                throw;
            }
            catch (Exception e)
            {
                if (!XmlException.IsCatchableException(e))
                {
                    throw;
                }
                // Note that XmlResolver or XmlReader may throw XmlException with SourceUri == null.
                // In that case we report current line information from XsltInput.
                XmlException ex = e as XmlException;
                ISourceLineInfo lineInfo = (ex != null && ex.SourceUri != null ?
                    new SourceLineInfo(ex.SourceUri, ex.LineNumber, ex.LinePosition, ex.LineNumber, ex.LinePosition) :
                    _input.BuildReaderLineInfo()
                );
                throw new XslLoadException(e, lineInfo);
            }
            finally
            {
                _documentUriInUse.Remove(baseUri);
                _input = prevInput;
                _curStylesheet = prevStylesheet;
            }
            return thisStylesheet;
        }
 public void Finish(XsltInput input)
 {
 }
 public void AddAttribute(XsltInput input)
 {
 }
        private Stylesheet LoadStylesheet(XmlReader reader, bool include) {
            string baseUri = reader.BaseURI;
            Debug.Assert(!documentUriInUse.Contains(baseUri), "Circular references must be checked while processing xsl:include and xsl:import");
            documentUriInUse.Add(baseUri, null);

            Stylesheet  prevStylesheet  = curStylesheet;
            XsltInput   prevInput       = input;
            Stylesheet  thisStylesheet  = include ? curStylesheet : compiler.CreateStylesheet();

            input         = new XsltInput(reader, compiler);
            curStylesheet = thisStylesheet;

            try {
                LoadDocument();
                if (!include) {
                    compiler.MergeWithStylesheet(curStylesheet);

                    List<Uri> importHrefs = curStylesheet.ImportHrefs;
                    curStylesheet.Imports = new Stylesheet[importHrefs.Count];
                    // We can't reverce imports order. Template lookup relies on it after compilation
                    // Imports should be compiled in the reverse order
                    for (int i = importHrefs.Count - 1; 0 <= i; i--) {
                        curStylesheet.Imports[i] = LoadStylesheet(importHrefs[i], /*include:*/false);
                    }
                }
            }
            catch (XslLoadException) {
                throw;
            }
            catch (Exception e) {
                if (!XmlException.IsCatchableException(e)) {
                    throw;
                }
                XmlException ex = e as XmlException;
                if (ex != null) {
                    SourceLineInfo lineInfo = new SourceLineInfo(input.Uri, ex.LineNumber, ex.LinePosition, ex.LineNumber, ex.LinePosition);
                    throw new XslLoadException(ex, lineInfo);
                }
                input.FixLastLineInfo();
                throw new XslLoadException(e, input.BuildLineInfo());
            }
            finally {
                documentUriInUse.Remove(baseUri);
                input         = prevInput;
                curStylesheet = prevStylesheet;
            }
            return thisStylesheet;
        }
 public ContextInfo(XsltInput input)
 {
     lineInfo       = input.BuildLineInfo();
     elemNameLength = input.QualifiedName.Length;
 }
Example #8
0
 public ContextInfo(XsltInput input) {
     elemNameLength = input.QualifiedName.Length;
 }
Example #9
0
            public void SaveExtendedLineInfo(XsltInput input) {
                if (lineInfo.Start.Line == 0) {
                    elemNameLi = endTagLi = null;
                    return;
                }

                elemNameLi = new SourceLineInfo(
                    lineInfo.Uri,
                    lineInfo.Start.Line, lineInfo.Start.Pos + 1,  // "<"
                    lineInfo.Start.Line, lineInfo.Start.Pos + 1 + elemNameLength
                );

                if (!input.IsEmptyElement) {
                    Debug.Assert(input.NodeType == XmlNodeType.EndElement);
                    endTagLi = input.BuildLineInfo();
                } else {
                    Debug.Assert(input.NodeType == XmlNodeType.Element || input.NodeType == XmlNodeType.Attribute);
                    endTagLi = new EmptyElementEndTag(lineInfo);
                }
            }
            public void SaveExtendedLineInfo(XsltInput input) {
                elemNameLi = new SourceLineInfo(
                    lineInfo.Uri,
                    lineInfo.StartLine, lineInfo.StartPos + 1,  // "<"
                    lineInfo.StartLine, lineInfo.StartPos + 1 + elemNameLength
                );

                if (!input.IsEmptyElement) {
                    Debug.Assert(input.reader.NodeType == XmlNodeType.EndElement);
                    endTagLi = input.BuildLineInfo();
                } else {
                    Debug.Assert(input.reader.NodeType == XmlNodeType.Element);
                    endTagLi = new EmptyElementEndTag(lineInfo);
                }
            }
 public void Finish(XsltInput input) {
 }
 public void AddNamespace(XsltInput input) {
     if (Ref.Equal(input.LocalName, input.Atoms.Xml)) {
         Debug.Assert(input.Value == XmlReservedNs.NsXml, "XmlReader must check binding for 'xml' prefix");
     } else {
         nsList = new NsDecl(nsList, input.LocalName, input.Value);
     }
 }
 public void AddAttribute(XsltInput input) {
 }
 public ContextInfo(XsltInput input) {
     lineInfo = input.BuildLineInfo();
     elemNameLength = input.QualifiedName.Length;
 }