System.Xml.Xsl.XsltOld.Compiler.GetNsAlias C# (CSharp) Method

GetNsAlias() public method

public GetNsAlias ( string &prefix ) : string
prefix string
return string
        public string GetNsAlias(ref string prefix)
        {
            Debug.Assert(
                Ref.Equal(_input.LocalName, _input.Atoms.StylesheetPrefix) ||
                Ref.Equal(_input.LocalName, _input.Atoms.ResultPrefix)
            );
            if (prefix == "#default")
            {
                prefix = string.Empty;
                return this.DefaultNamespace;
            }
            else
            {
                if (!PrefixQName.ValidatePrefix(prefix))
                {
                    throw XsltException.Create(SR.Xslt_InvalidAttrValue, _input.LocalName, prefix);
                }
                return this.ResolveXPathNamespace(prefix);
            }
        }

Usage Example

Ejemplo n.º 1
0
        internal void CompileNamespaceAlias(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;
            string         element = input.LocalName;
            string?        namespace1 = null, namespace2 = null;
            string?        prefix1 = null, prefix2 = null;

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

                    if (nspace.Length != 0)
                    {
                        continue;
                    }

                    if (Ref.Equal(name, input.Atoms.StylesheetPrefix))
                    {
                        prefix1    = input.Value;
                        namespace1 = compiler.GetNsAlias(ref prefix1);
                    }
                    else if (Ref.Equal(name, input.Atoms.ResultPrefix))
                    {
                        prefix2    = input.Value;
                        namespace2 = compiler.GetNsAlias(ref prefix2);
                    }
                    else
                    {
                        if (!compiler.ForwardCompatibility)
                        {
                            throw XsltException.Create(SR.Xslt_InvalidAttribute, name, element);
                        }
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }

            CheckRequiredAttribute(compiler, namespace1, "stylesheet-prefix");
            CheckRequiredAttribute(compiler, namespace2, "result-prefix");
            CheckEmpty(compiler);

            //String[] resultarray = { prefix2, namespace2 };
            compiler.AddNamespaceAlias(namespace1 !, new NamespaceInfo(prefix2, namespace2, compiler.Stylesheetid));
        }
All Usage Examples Of System.Xml.Xsl.XsltOld.Compiler::GetNsAlias