Ejemplo n.º 1
0
        internal override void Compile(Compiler compiler)
        {
            this.stylesheetid = compiler.Stylesheetid;
            this.baseUri = compiler.Input.BaseURI;
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.name, "name");


            if (compiler.Recurse())
            {
                CompileTemplate(compiler);
                compiler.ToParent();

                if (this.selectKey != Compiler.InvalidQueryKey && this.containedActions != null)
                {
                    throw XsltException.Create(SR.Xslt_VariableCntSel2, this.nameStr);
                }
            }
            if (this.containedActions != null)
            {
                baseUri = baseUri + '#' + compiler.GetUnicRtfId();
            }
            else
            {
                baseUri = null;
            }

            _varKey = compiler.InsertVariable(this);
        }
        private void CompileContent(Compiler compiler) {
            NavigatorInput input = compiler.Input;
            
            if (compiler.Recurse()) {
                do {
                    switch(input.NodeType) {
                    case XPathNodeType.Element:
                        compiler.PushNamespaceScope();
                        string nspace = input.NamespaceURI;
                        string name   = input.LocalName;

                        if (Ref.Equal(nspace, input.Atoms.UriXsl) && Ref.Equal(name, input.Atoms.WithParam)) {
                                WithParamAction par = compiler.CreateWithParamAction();
                                CheckDuplicateParams(par.Name);
                                AddAction(par);
                        }
                        else {
                            throw compiler.UnexpectedKeyword();
                        }
                        compiler.PopScope();
                        break;
                    case XPathNodeType.Comment:
                    case XPathNodeType.ProcessingInstruction:
                    case XPathNodeType.Whitespace:
                    case XPathNodeType.SignificantWhitespace:
                        break;
                    default:
                        throw XsltException.Create(Res.Xslt_InvalidContents, "call-template");
                    }
                } while(compiler.Advance());

                compiler.ToParent();
            }
        }
Ejemplo n.º 3
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            if (_matchKey == Compiler.InvalidQueryKey)
            {
                if (_name == null)
                {
                    throw XsltException.Create(SR.Xslt_TemplateNoAttrib);
                }
                if (_mode != null)
                {
                    throw XsltException.Create(SR.Xslt_InvalidModeAttribute);
                }
            }
            compiler.BeginTemplate(this);

            if (compiler.Recurse())
            {
                CompileParameters(compiler);
                CompileTemplate(compiler);

                compiler.ToParent();
            }

            compiler.EndTemplate();
            AnalyzePriority(compiler);
        }
Ejemplo n.º 4
0
        public void CompileAttributes(Compiler compiler) {
            NavigatorInput input   = compiler.Input;
            string         element = input.LocalName;

            if (input.MoveToFirstAttribute()) {
                do {
                    if (input.NamespaceURI.Length != 0) continue;

                    try {
                        if (CompileAttribute(compiler) == false) {
                            throw XsltException.Create(Res.Xslt_InvalidAttribute, input.LocalName, element);
                        }
                    }catch {
                        if (! compiler.ForwardCompatibility) {
                            throw;
                        }
                        else {
                            // In ForwardCompatibility mode we ignoreing all unknown or incorrect attributes
                            // If it's mandatory attribute we'l notice it absents later.
                        }
                    }
                }
                while (input.MoveToNextAttribute());
                input.ToParent();
            }
        }
Ejemplo n.º 5
0
 public DbgData(Compiler compiler)
 {
     DbgCompiler dbgCompiler = (DbgCompiler)compiler;
     _styleSheet = dbgCompiler.Input.Navigator.Clone();
     _variables = dbgCompiler.LocalVariables;
     dbgCompiler.Debugger.OnInstructionCompile(this.StyleSheet);
 }
Ejemplo n.º 6
0
        internal override void Compile(Compiler compiler)
        {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, _nameAvt, "name");

            _name = PrecalculateAvt(ref _nameAvt);
            _nsUri = PrecalculateAvt(ref _nsAvt);

            // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore
            if (_nameAvt == null && _nsAvt == null)
            {
                if (_name != "xmlns")
                {
                    _qname = CreateAttributeQName(_name, _nsUri, compiler.CloneScopeManager());
                }
            }
            else
            {
                _manager = compiler.CloneScopeManager();
            }

            if (compiler.Recurse())
            {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Ejemplo n.º 7
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;

            if (Ref.Equal(name, compiler.Atoms.Match)) {
                Debug.Assert(this.matchKey == Compiler.InvalidQueryKey);
                this.matchKey = compiler.AddQuery(value, /*allowVars:*/false, /*allowKey:*/true, /*pattern*/true);
            }
            else if (Ref.Equal(name, compiler.Atoms.Name)) {
                Debug.Assert(this.name == null);
                this.name = compiler.CreateXPathQName(value);
            }
            else if (Ref.Equal(name, compiler.Atoms.Priority)) {
                Debug.Assert(Double.IsNaN(this.priority));
                this.priority = XmlConvert.ToXPathDouble(value);
                if (double.IsNaN(this.priority) && ! compiler.ForwardCompatibility) {
                    throw XsltException.Create(Res.Xslt_InvalidAttrValue, "priority", value);
                }
            }
            else if (Ref.Equal(name, compiler.Atoms.Mode)) {
                Debug.Assert(this.mode == null);
                if (compiler.AllowBuiltInMode && value == "*") {
                    this.mode = Compiler.BuiltInMode;
                }
                else {
                    this.mode = compiler.CreateXPathQName(value);
                }
            }
            else {
                return false;
            }

            return true;
        }
        internal override void Compile(Compiler compiler) {
            Debug.Assert(Ref.Equal(compiler.Input.LocalName, compiler.Atoms.UseAttributeSets));
            this.useString = compiler.Input.Value;

            Debug.Assert(this.useAttributeSets == null);

            if (this.useString.Length == 0) {
                // Split creates empty node is spliting empty string
                this.useAttributeSets = new XmlQualifiedName[0];
                return;
            }

            string[] qnames = XmlConvert.SplitString(this.useString);

            try {
                this.useAttributeSets = new XmlQualifiedName[qnames.Length]; {
                    for (int i = 0; i < qnames.Length; i++) {
                        this.useAttributeSets[i] = compiler.CreateXPathQName(qnames[i]);
                    }
                }
            }
            catch (XsltException) {
                if (!compiler.ForwardCompatibility) {
                    // Rethrow the exception if we're not in forwards-compatible mode
                    throw;
                }
                // Ignore the whole list in forwards-compatible mode
                this.useAttributeSets = new XmlQualifiedName[0];
            }
        }
Ejemplo n.º 9
0
        private void CompileContent(Compiler compiler)
        {
            if (compiler.Recurse())
            {
                NavigatorInput input = compiler.Input;

                _text = string.Empty;

                do
                {
                    switch (input.NodeType)
                    {
                        case XPathNodeType.Text:
                        case XPathNodeType.Whitespace:
                        case XPathNodeType.SignificantWhitespace:
                            _text += input.Value;
                            break;
                        case XPathNodeType.Comment:
                        case XPathNodeType.ProcessingInstruction:
                            break;
                        default:
                            throw compiler.UnexpectedKeyword();
                    }
                } while (compiler.Advance());
                compiler.ToParent();
            }
        }
Ejemplo n.º 10
0
        internal virtual void CompileSingle(Compiler compiler)
        {
            _matchKey = compiler.AddQuery("/", /*allowVars:*/false, /*allowKey:*/true, /*pattern*/true);
            _priority = Compiler.RootPriority;

            CompileOnceTemplate(compiler);
        }
Ejemplo n.º 11
0
        internal override bool CompileAttribute(Compiler compiler)
        {
            string name = compiler.Input.LocalName;
            string value = compiler.Input.Value;
            if (Ref.Equal(name, compiler.Atoms.Select))
            {
                _selectKey = compiler.AddQuery(value);
            }
            else if (Ref.Equal(name, compiler.Atoms.Mode))
            {
                Debug.Assert(_mode == null);
                if (compiler.AllowBuiltInMode && value == "*")
                {
                    _mode = Compiler.BuiltInMode;
                }
                else
                {
                    _mode = compiler.CreateXPathQName(value);
                }
            }
            else
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 12
0
        internal static Avt CompileAvt(Compiler compiler, string avtText) {
            Debug.Assert(compiler != null);
            Debug.Assert(avtText != null);

            bool constant;
            ArrayList list = compiler.CompileAvt(avtText, out constant);
            return constant ? new Avt(avtText) : new Avt(list);
        }
Ejemplo n.º 13
0
 internal override void ReplaceNamespaceAlias(Compiler compiler)
 {
     int count = _copyEvents.Count;
     for (int i = 0; i < count; i++)
     {
         ((Event)_copyEvents[i]).ReplaceNamespaceAlias(compiler);
     }
 }
Ejemplo n.º 14
0
 internal override void Compile(Compiler compiler) {
     CheckEmpty(compiler);
     if (! compiler.CanHaveApplyImports) {
         throw XsltException.Create(Res.Xslt_ApplyImports);                
     }
     this.mode = compiler.CurrentMode;
     this.stylesheet = compiler.CompiledStylesheet;
 }
Ejemplo n.º 15
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileConditions(compiler);
                compiler.ToParent();
            }
        }
Ejemplo n.º 16
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Ejemplo n.º 17
0
 internal override void Compile(Compiler compiler) {
     XPathNavigator nav = compiler.Input.Navigator.Clone();
     name = nav.Name;
     nav.MoveToParent();
     parent = nav.Name;
     if (compiler.Recurse()) {
         CompileSelectiveTemplate(compiler);
         compiler.ToParent();
     }
 }
Ejemplo n.º 18
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            if (this.type != ConditionType.ConditionOtherwise) {
                CheckRequiredAttribute(compiler, this.testKey != Compiler.InvalidQueryKey, "test");
            }

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
Ejemplo n.º 19
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);

            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();
            }
            if (this.containedActions == null)
                this.empty = true;
                
        }
Ejemplo n.º 20
0
        private void CompileConditions(Compiler compiler) {
            NavigatorInput input = compiler.Input;
            bool when       = false;
            bool otherwise  = false;

            do {
                switch (input.NodeType) {
                case XPathNodeType.Element:
                    compiler.PushNamespaceScope();
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (Ref.Equal(nspace, input.Atoms.UriXsl)) {
                        IfAction action = null;
                        if (Ref.Equal(name, input.Atoms.When)) {
                            if (otherwise) {
                                throw XsltException.Create(Res.Xslt_WhenAfterOtherwise);
                            }
                            action = compiler.CreateIfAction(IfAction.ConditionType.ConditionWhen);
                            when = true;
                        }
                        else if (Ref.Equal(name, input.Atoms.Otherwise)) {
                            if (otherwise) {
                                throw XsltException.Create(Res.Xslt_DupOtherwise);
                            }
                            action = compiler.CreateIfAction(IfAction.ConditionType.ConditionOtherwise);
                            otherwise = true;
                        }
                        else {
                            throw compiler.UnexpectedKeyword();
                        }
                        AddAction(action);
                    }
                    else {
                        throw compiler.UnexpectedKeyword();
                    }
                    compiler.PopScope();
                    break;

                case XPathNodeType.Comment:
                case XPathNodeType.ProcessingInstruction:
                case XPathNodeType.Whitespace:
                case XPathNodeType.SignificantWhitespace:
                    break;

                default:
                    throw XsltException.Create(Res.Xslt_InvalidContents, "choose");
                }
            }
            while (compiler.Advance());
            if (! when) {
                throw XsltException.Create(Res.Xslt_NoWhen);
            }
        }
Ejemplo n.º 21
0
 public override void ReplaceNamespaceAlias(Compiler compiler){
     if (this.namespaceUri.Length != 0) { // Do we need to check this for namespace?
         NamespaceInfo ResultURIInfo = compiler.FindNamespaceAlias(this.namespaceUri);
         if (ResultURIInfo != null) {
             this.namespaceUri = ResultURIInfo.nameSpace;
             if (ResultURIInfo.prefix != null) {
                 this.name = ResultURIInfo.prefix;
             }
         }
     }
 }
Ejemplo n.º 22
0
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, selectKey != Compiler.InvalidQueryKey, Keywords.s_Select);

            compiler.CanHaveApplyImports = false;
            if (compiler.Recurse()) {
                CompileSortElements(compiler);
                CompileTemplate(compiler);
                compiler.ToParent();
            }
        }
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Keywords.Equals(name, compiler.Atoms.Name)) {
                this.nameAvt = Avt.CompileAvt(compiler, value);
            }
            else {
                return false;
            }

            return true;
        }
        internal override void Compile(Compiler compiler) {
            CompileAttributes(compiler);
            CheckRequiredAttribute(compiler, this.name, Keywords.s_Name);
            if (compiler.Recurse()) {
                CompileTemplate(compiler);
                compiler.ToParent();

                if (this.selectKey != Compiler.InvalidQueryKey && this.containedActions != null) {
                    throw XsltException.Create(Res.Xslt_VariableCntSel2, this.nameStr);
                }
            }
        }
Ejemplo n.º 25
0
 internal override bool CompileAttribute(Compiler compiler) {
     string name   = compiler.Input.LocalName;
     string value  = compiler.Input.Value;
     if (Ref.Equal(name, compiler.Atoms.UseAttributeSets)) {
         this.useAttributeSets = value;
         AddAction(compiler.CreateUseAttributeSetsAction());
     }
     else {
         return false;
     }
     return true;
 }
Ejemplo n.º 26
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Ref.Equal(name, compiler.Atoms.Select)) {
                this.selectKey = compiler.AddQuery(value);
            }
            else {
                return false;
            }

            return true;
        }
Ejemplo n.º 27
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Ref.Equal(name, compiler.Atoms.Terminate)) {
                _Terminate = compiler.GetYesNo(value);
            }
            else {
                return false;
            }

            return true;
        }
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;
            if (Ref.Equal(name, compiler.Atoms.Name)) {
                Debug.Assert(this.name == null);
                this.name = compiler.CreateXPathQName(value);
            }
            else {
                return false;
            }

            return true;
        }
Ejemplo n.º 29
0
        internal override bool CompileAttribute(Compiler compiler) {
            string name   = compiler.Input.LocalName;
            string value  = compiler.Input.Value;

            if (Ref.Equal(name, compiler.Atoms.DisableOutputEscaping)) {
                this.disableOutputEscaping = compiler.GetYesNo(value);
            }
            else {
                return false;
            }

            return true;
        }
        internal void CompileStylesheetAttributes(Compiler compiler) {
            NavigatorInput input        = compiler.Input;
            string         element      = input.LocalName;
            string         badAttribute = null;
            string         version      = null;

            if (input.MoveToFirstAttribute()) {
                do {
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (nspace.Length != 0) continue;

                    if (Ref.Equal(name, input.Atoms.Version)) {
                        version = input.Value;
                        if (1 <= XmlConvert.ToXPathDouble(version)) {
                            compiler.ForwardCompatibility = (version != "1.0");
                        }
                        else {
                            // XmlConvert.ToXPathDouble(version) an be NaN!
                            if (! compiler.ForwardCompatibility) {
                                throw XsltException.Create(Res.Xslt_InvalidAttrValue, "version", version);
                            }
                        }
                    }
                    else if (Ref.Equal(name, input.Atoms.ExtensionElementPrefixes)) {
                        compiler.InsertExtensionNamespace(input.Value);
                    }
                    else if (Ref.Equal(name, input.Atoms.ExcludeResultPrefixes)) {
                        compiler.InsertExcludedNamespace(input.Value);
                    }
                    else if (Ref.Equal(name, input.Atoms.Id)) {
                        // Do nothing here.
                    }
                    else {
                        // We can have version atribute later. For now remember this attribute and continue
                        badAttribute = name;
                    }
                }
                while( input.MoveToNextAttribute());
                input.ToParent();
            }

            if (version == null) {
                throw XsltException.Create(Res.Xslt_MissingAttribute, "version");
            }

            if (badAttribute != null && ! compiler.ForwardCompatibility) {
                throw XsltException.Create(Res.Xslt_InvalidAttribute, badAttribute, element);
            }
        }
Ejemplo n.º 31
0
        private void CompileConditions(Compiler compiler)
        {
            NavigatorInput input     = compiler.Input;
            bool           when      = false;
            bool           otherwise = false;

            do
            {
                switch (input.NodeType)
                {
                case XPathNodeType.Element:
                    compiler.PushNamespaceScope();
                    string nspace = input.NamespaceURI;
                    string name   = input.LocalName;

                    if (Ref.Equal(nspace, input.Atoms.UriXsl))
                    {
                        IfAction action = null;
                        if (Ref.Equal(name, input.Atoms.When))
                        {
                            if (otherwise)
                            {
                                throw XsltException.Create(SR.Xslt_WhenAfterOtherwise);
                            }
                            action = compiler.CreateIfAction(IfAction.ConditionType.ConditionWhen);
                            when   = true;
                        }
                        else if (Ref.Equal(name, input.Atoms.Otherwise))
                        {
                            if (otherwise)
                            {
                                throw XsltException.Create(SR.Xslt_DupOtherwise);
                            }
                            action    = compiler.CreateIfAction(IfAction.ConditionType.ConditionOtherwise);
                            otherwise = true;
                        }
                        else
                        {
                            throw compiler.UnexpectedKeyword();
                        }
                        AddAction(action);
                    }
                    else
                    {
                        throw compiler.UnexpectedKeyword();
                    }
                    compiler.PopScope();
                    break;

                case XPathNodeType.Comment:
                case XPathNodeType.ProcessingInstruction:
                case XPathNodeType.Whitespace:
                case XPathNodeType.SignificantWhitespace:
                    break;

                default:
                    throw XsltException.Create(SR.Xslt_InvalidContents, "choose");
                }
            }while (compiler.Advance());
            if (!when)
            {
                throw XsltException.Create(SR.Xslt_NoWhen);
            }
        }
Ejemplo n.º 32
0
 public BeginEventDbg(Compiler compiler) : base(compiler)
 {
     _dbgData = new DbgData(compiler);
 }
Ejemplo n.º 33
0
 internal abstract void Compile(Compiler compiler);
Ejemplo n.º 34
0
 public TextEventDbg(Compiler compiler) : base(compiler)
 {
     _dbgData = new DbgData(compiler);
 }
Ejemplo n.º 35
0
 internal override void Compile(Compiler compiler)
 {
     _dbgData = new DbgData(compiler);
     base.Compile(compiler);
     ((DbgCompiler)compiler).DefineVariable(this);
 }
Ejemplo n.º 36
0
 public virtual void ReplaceNamespaceAlias(Compiler compiler)
 {
 }
Ejemplo n.º 37
0
 internal virtual void ReplaceNamespaceAlias(Compiler compiler)
 {
 }
Ejemplo n.º 38
0
 /*
  * Compile
  */
 internal override void Compile(Compiler compiler)
 {
     CompileDocument(compiler, /*inInclude*/ false);
 }
Ejemplo n.º 39
0
 internal virtual bool CompileAttribute(Compiler compiler)
 {
     return(false);
 }
Ejemplo n.º 40
0
 internal override void Compile(Compiler compiler)
 {
     base.Compile(compiler);
 }
 internal override void Compile(Compiler compiler)
 {
     CompileAttributes(compiler);
     CompileContent(compiler);
 }
Ejemplo n.º 42
0
 internal override void Compile(Compiler compiler)
 {
     CompileAttributes(compiler);
     CheckRequiredAttribute(compiler, this.name, "name");
     CompileContent(compiler);
 }
Ejemplo n.º 43
0
 public void CheckRequiredAttribute(Compiler compiler, object attrValue, string attrName)
 {
     CheckRequiredAttribute(compiler, attrValue != null, attrName);
 }