SetQName() private méthode

private SetQName ( string qname ) : void
qname string
Résultat void
        private PrefixQName       qname; // When we not have AVTs at all we can do this. null otherwise.

        private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager) {
            // if name == "xmlns" we don't need to generate this attribute.
            // to avoid i'ts generation we can return false and not add AtributeCation to it's parent container action
            // for now not creating this.qname will do the trick at execution time
            if (name  == "xmlns") return null;
            if (nsUri == XmlReservedNs.NsXmlNs) {
                throw XsltException.Create(Res.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();
            qname.SetQName(name);

            qname.Namespace = nsUri != null ? nsUri : manager.ResolveXPathNamespace(qname.Prefix);

            if (qname.Prefix.StartsWith("xml", StringComparison.Ordinal)) {
                if (qname.Prefix.Length == 3) { // prefix == "xml"
                    if (qname.Namespace == XmlReservedNs.NsXml && (qname.Name == "lang" || qname.Name == "space")) {
                        // preserve prefix for xml:lang and xml:space
                    }
                    else {
                        qname.ClearPrefix();
                    }
                }
                else if (qname.Prefix == "xmlns") {
                    if (qname.Namespace == XmlReservedNs.NsXmlNs) {
                        // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns' 
                        throw XsltException.Create(Res.Xslt_InvalidPrefix, qname.Prefix);
                    }
                    else {
                        qname.ClearPrefix();
                    }
                }
            }
            return qname;
        }
Exemple #2
0
        private static PrefixQName?CreateAttributeQName(string name, string?nsUri, InputScopeManager?manager)
        {
            // if name == "xmlns" we don't need to generate this attribute.
            // to avoid its generation we can return false and not add AttributeCreation to it's parent container action
            // for now not creating this.qname will do the trick at execution time
            if (name == "xmlns")
            {
                return(null);
            }
            if (nsUri == XmlReservedNs.NsXmlNs)
            {
                throw XsltException.Create(SR.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();

            qname.SetQName(name);

            qname.Namespace = nsUri != null ? nsUri : manager !.ResolveXPathNamespace(qname.Prefix);

            if (qname.Prefix.StartsWith("xml", StringComparison.Ordinal))
            {
                if (qname.Prefix.Length == 3)
                { // prefix == "xml"
                    if (qname.Namespace == XmlReservedNs.NsXml && (qname.Name == "lang" || qname.Name == "space"))
                    {
                        // preserve prefix for xml:lang and xml:space
                    }
                    else
                    {
                        qname.ClearPrefix();
                    }
                }
                else if (qname.Prefix == "xmlns")
                {
                    if (qname.Namespace == XmlReservedNs.NsXmlNs)
                    {
                        // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns'
                        throw XsltException.Create(SR.Xslt_InvalidPrefix, qname.Prefix);
                    }
                    else
                    {
                        qname.ClearPrefix();
                    }
                }
            }
            return(qname);
        }
        private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager) {
            if (nsUri == XmlReservedNs.NsXmlNs) {
                throw XsltException.Create(Res.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();
            qname.SetQName(name);

            if (nsUri == null) {
                qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix);
            }
            else {
                qname.Namespace = nsUri;
            }
            return qname;
        }
Exemple #4
0
        private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager)
        {
            if (nsUri == XmlReservedNs.NsXmlNs)
            {
                throw XsltException.Create(SR.Xslt_ReservedNS, nsUri);
            }

            PrefixQName qname = new PrefixQName();

            qname.SetQName(name);

            if (nsUri == null)
            {
                qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix);
            }
            else
            {
                qname.Namespace = nsUri;
            }
            return(qname);
        }