private GenericOutputter(Hashtable outputs, Encoding encoding)
 {
     this._encoding              = encoding;
     this._outputs               = outputs;
     this._currentOutput         = (XslOutput)outputs[string.Empty];
     this._state                 = WriteState.Prolog;
     this._nt                    = new NameTable();
     this._nsManager             = new XmlNamespaceManager(this._nt);
     this._currentNamespaceDecls = new ListDictionary();
     this._omitXmlDeclaration    = false;
 }
Example #2
0
		public HtmlEmitter (TextWriter writer, XslOutput output)
		{
			this.writer = writer;
			indent = output.Indent == "yes" || output.Indent == null;
			elementNameStack = new Stack ();
			nonHtmlDepth = -1;
			outputEncoding = writer.Encoding == null ? output.Encoding : writer.Encoding;
			mediaType = output.MediaType;
			if (mediaType == null || mediaType.Length == 0)
				mediaType = "text/html";
		}
Example #3
0
		private GenericOutputter (Hashtable outputs, Encoding encoding)
		{
			_encoding = encoding;
			_outputs = outputs;
			_currentOutput = (XslOutput)outputs [String.Empty];
			_state = WriteState.Prolog;
			//TODO: Optimize using nametable
			_nt = new NameTable ();
			_nsManager = new XmlNamespaceManager (_nt);
			_currentNamespaceDecls = new ListDictionary ();
			_omitXmlDeclaration = false;
		}
Example #4
0
 private GenericOutputter(Hashtable outputs, Encoding encoding)
 {
     _encoding      = encoding;
     _outputs       = outputs;
     _currentOutput = (XslOutput)outputs [String.Empty];
     _state         = WriteState.Prolog;
     //TODO: Optimize using nametable
     _nt                    = new NameTable();
     _nsManager             = new XmlNamespaceManager(_nt);
     _currentNamespaceDecls = new ListDictionary();
     _omitXmlDeclaration    = false;
 }
 public HtmlEmitter(TextWriter writer, XslOutput output)
 {
     this.writer           = writer;
     this.indent           = (output.Indent == "yes" || output.Indent == null);
     this.elementNameStack = new Stack();
     this.nonHtmlDepth     = -1;
     this.outputEncoding   = ((writer.Encoding != null) ? writer.Encoding : output.Encoding);
     this.mediaType        = output.MediaType;
     if (this.mediaType == null || this.mediaType.Length == 0)
     {
         this.mediaType = "text/html";
     }
 }
Example #6
0
        public void CompileOutput()
        {
            XPathNavigator n      = Input;
            string         uri    = n.GetAttribute("href", "");
            XslOutput      output = outputs [uri] as XslOutput;

            if (output == null)
            {
                output = new XslOutput(uri, stylesheetVersion);
                outputs.Add(uri, output);
            }
            output.Fill(n);
        }
Example #7
0
        public void CompileOutput()
        {
            XPathNavigator input     = this.Input;
            string         attribute = input.GetAttribute("href", string.Empty);
            XslOutput      xslOutput = this.outputs[attribute] as XslOutput;

            if (xslOutput == null)
            {
                xslOutput = new XslOutput(attribute, this.stylesheetVersion);
                this.outputs.Add(attribute, xslOutput);
            }
            xslOutput.Fill(input);
        }
Example #8
0
 public HtmlEmitter(TextWriter writer, XslOutput output)
 {
     this.writer      = writer;
     indent           = output.Indent == "yes" || output.Indent == null;
     elementNameStack = new Stack();
     nonHtmlDepth     = -1;
     outputEncoding   = writer.Encoding == null ? output.Encoding : writer.Encoding;
     mediaType        = output.MediaType;
     if (mediaType == null || mediaType.Length == 0)
     {
         mediaType = "text/html";
     }
 }
Example #9
0
        public CompiledStylesheet Compile(XPathNavigator nav, XmlResolver res, Evidence evidence)
        {
            this.xpathParser   = new XPathParser(this);
            this.patternParser = new XsltPatternParser(this);
            this.res           = res;
            if (res == null)
            {
                this.res = new XmlUrlResolver();
            }
            this.evidence = evidence;

            // reject empty document.
            if (nav.NodeType == XPathNodeType.Root && !nav.MoveToFirstChild())
            {
                throw new XsltCompileException("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element", null, nav);
            }
            while (nav.NodeType != XPathNodeType.Element)
            {
                nav.MoveToNext();
            }

            stylesheetVersion = nav.GetAttribute("version",
                                                 (nav.NamespaceURI != XsltNamespace) ?
                                                 XsltNamespace : String.Empty);
            outputs [""] = new XslOutput("", stylesheetVersion);

            PushInputDocument(nav);
            if (nav.MoveToFirstNamespace(XPathNamespaceScope.ExcludeXml))
            {
                do
                {
                    nsMgr.AddNamespace(nav.LocalName, nav.Value);
                }while (nav.MoveToNextNamespace(XPathNamespaceScope.ExcludeXml));
                nav.MoveToParent();
            }
            try
            {
                rootStyle = new XslStylesheet();
                rootStyle.Compile(this);
            }
            catch (XsltCompileException)
            {
                throw;
            }
            catch (Exception x)
            {
                throw new XsltCompileException("XSLT compile error. " + x.Message, x, Input);
            }

            return(new CompiledStylesheet(rootStyle, globalVariables, attrSets, nsMgr, keys, outputs, decimalFormats, msScripts));
        }
Example #10
0
        private void DetermineOutputMethod(string localName, string ns)
        {
            XslOutput xslOutput = (XslOutput)_outputs [String.Empty];

            switch (xslOutput.Method)
            {
            default:                     // .Custom format is not supported, only handled as unknown
            case OutputMethod.Unknown:
                if (localName != null && String.Compare(localName, "html", true, CultureInfo.InvariantCulture) == 0 && ns == String.Empty)
                {
                    goto case OutputMethod.HTML;
                }
                goto case OutputMethod.XML;

            case OutputMethod.HTML:
                _emitter = new HtmlEmitter(pendingTextWriter, xslOutput);
                break;

            case OutputMethod.XML:
                XmlTextWriter w = new XmlTextWriter(pendingTextWriter);
                if (xslOutput.Indent == "yes")
                {
                    w.Formatting = Formatting.Indented;
                }

                _emitter = new XmlWriterEmitter(w);
                if (!_omitXmlDeclaration && !xslOutput.OmitXmlDeclaration)
                {
                    _emitter.WriteStartDocument(
                        _encoding != null ? _encoding : xslOutput.Encoding,
                        xslOutput.Standalone);
                }

                break;

            case OutputMethod.Text:
                _emitter = new TextEmitter(pendingTextWriter);
                break;
            }
            pendingTextWriter = null;
        }
        private void DetermineOutputMethod(string localName, string ns)
        {
            XslOutput xslOutput = (XslOutput)this._outputs[string.Empty];

            switch (xslOutput.Method)
            {
            case OutputMethod.XML:
                goto IL_89;

            case OutputMethod.HTML:
                break;

            case OutputMethod.Text:
                this._emitter = new TextEmitter(this.pendingTextWriter);
                goto IL_11B;

            default:
                if (localName == null || string.Compare(localName, "html", true, CultureInfo.InvariantCulture) != 0 || !(ns == string.Empty))
                {
                    goto IL_89;
                }
                break;
            }
            this._emitter = new HtmlEmitter(this.pendingTextWriter, xslOutput);
            goto IL_11B;
IL_89:
            XmlTextWriter xmlTextWriter = new XmlTextWriter(this.pendingTextWriter);

            if (xslOutput.Indent == "yes")
            {
                xmlTextWriter.Formatting = Formatting.Indented;
            }
            this._emitter = new XmlWriterEmitter(xmlTextWriter);
            if (!this._omitXmlDeclaration && !xslOutput.OmitXmlDeclaration)
            {
                this._emitter.WriteStartDocument((this._encoding == null) ? xslOutput.Encoding : this._encoding, xslOutput.Standalone);
            }
IL_11B:
            this.pendingTextWriter = null;
        }
Example #12
0
		public void CompileOutput ()
		{
			XPathNavigator n = Input;
			string uri = n.GetAttribute ("href", "");
			XslOutput output = outputs [uri] as XslOutput;
			if (output == null) {
				output = new XslOutput (uri, stylesheetVersion);
				outputs.Add (uri, output);
			}
			output.Fill (n);
		}
Example #13
0
		public CompiledStylesheet Compile (XPathNavigator nav, XmlResolver res, Evidence evidence)
		{
			this.xpathParser = new XPathParser (this);
			this.patternParser = new XsltPatternParser (this);
			this.res = res;
			if (res == null)
				this.res = new XmlUrlResolver ();
			this.evidence = evidence;

			// reject empty document.
			if (nav.NodeType == XPathNodeType.Root && !nav.MoveToFirstChild ())
				throw new XsltCompileException ("Stylesheet root element must be either \"stylesheet\" or \"transform\" or any literal element", null, nav);
			while (nav.NodeType != XPathNodeType.Element) nav.MoveToNext();
			
			stylesheetVersion = nav.GetAttribute ("version", 
				(nav.NamespaceURI != XsltNamespace) ?
				XsltNamespace : String.Empty);
			outputs [""] = new XslOutput ("", stylesheetVersion);
				
			PushInputDocument (nav);
			if (nav.MoveToFirstNamespace (XPathNamespaceScope.ExcludeXml))
			{
				do {
					nsMgr.AddNamespace (nav.LocalName, nav.Value);
				} while (nav.MoveToNextNamespace (XPathNamespaceScope.ExcludeXml));
				nav.MoveToParent ();
			}
			try {
				rootStyle = new XslStylesheet ();
				rootStyle.Compile (this);
			} catch (XsltCompileException) {
				throw;
			} catch (Exception x) {
				throw new XsltCompileException ("XSLT compile error. " + x.Message, x,  Input);
			}
			
			return new CompiledStylesheet (rootStyle, globalVariables, attrSets, nsMgr, keys, outputs, decimalFormats, msScripts);
		}