public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            string nm, nmsp, prefix;

            nm   = calcName != null ? calcName : name.Evaluate(p);
            nmsp = calcNs != null ? calcNs : ns != null?ns.Evaluate(p) : String.Empty;

            prefix = calcPrefix != null ? calcPrefix : String.Empty;

            if (nm == "xmlns")
            {
                // It is an error. We must recover by not emmiting any attributes
                // (unless we throw an exception).
                return;
            }

            int colonAt = nm.IndexOf(':');

            // local attribute
            if (colonAt > 0)
            {
                prefix = nm.Substring(0, colonAt);
                nm     = nm.Substring(colonAt + 1);

                // global attribute
                if (nmsp == String.Empty &&
                    prefix == XmlNamespaceManager.PrefixXml)
                {
                    nmsp = XmlNamespaceManager.XmlnsXml;
                }
                else if (nmsp == String.Empty)
                {
                    nmsp = (string)nsDecls [prefix];
                    if (nmsp == null)
                    {
                        nmsp = String.Empty;
                    }
                }
            }

            if (prefix == "xmlns")
            {
                prefix = String.Empty;  // Should not be allowed.
            }
            XmlConvert.VerifyName(nm);

            p.Out.WriteAttributeString(prefix, nm, nmsp,
                                       value == null ? "" : value.EvaluateAsString(p));
        }
Ejemplo n.º 2
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            string actualName = name.Evaluate(p);

            if (String.Compare(actualName, "xml", true, CultureInfo.InvariantCulture) == 0)
            {
                throw new XsltException("Processing instruction name was evaluated to \"xml\"", null, p.CurrentNode);
            }
            if (actualName.IndexOf(':') >= 0)
            {
                return; //MS.NET ignores such processing instructions
            }
            p.Out.WriteProcessingInstruction(actualName,
                                             value == null ? String.Empty :
                                             value.EvaluateAsString(p));
        }
Ejemplo n.º 3
0
        public override void Evaluate(XslTransformProcessor p)
        {
            if (p.Debugger != null)
            {
                p.Debugger.DebugExecute(p, this.DebugInput);
            }

            string nm, nmsp, localName, prefix;

            localName = nm = calcName != null ? calcName : name.Evaluate(p);
            nmsp      = calcNs != null ? calcNs : ns != null?ns.Evaluate(p) : null;

            QName q = XslNameUtil.FromString(nm, nsDecls);

            localName = q.Name;
            if (nmsp == null)
            {
                nmsp = q.Namespace;
            }
            int colonAt = nm.IndexOf(':');

            if (colonAt > 0)
            {
                calcPrefix = nm.Substring(0, colonAt);
            }
            else if (colonAt == 0)
            {
                // raises an error
                XmlConvert.VerifyNCName(String.Empty);
            }

            prefix = calcPrefix != null ? calcPrefix : String.Empty;

            if (prefix != String.Empty)
            {
                XmlConvert.VerifyNCName(prefix);
            }
            XmlConvert.VerifyNCName(localName);

            bool isCData = p.InsideCDataElement;

            p.PushElementState(prefix, localName, nmsp, false);
            p.Out.WriteStartElement(prefix, localName, nmsp);

            if (useAttributeSets != null)
            {
                foreach (XmlQualifiedName s in useAttributeSets)
                {
                    p.ResolveAttributeSet(s).Evaluate(p);
                }
            }

            if (value != null)
            {
                value.Evaluate(p);
            }

            if (isEmptyElement && useAttributeSets == null)
            {
                p.Out.WriteEndElement();
            }
            else
            {
                p.Out.WriteFullEndElement();
            }
            p.PopCDataState(isCData);
        }
Ejemplo n.º 4
0
 public void Evaluate(XslTransformProcessor p)
 {
     //FIXME: fix attribute prefixes according to aliases
     p.Out.WriteAttributeString(prefix, localname, nsUri, val.Evaluate(p));
 }