XML and XSLT to generate CSS?
I want to provide user facility to change the CSS.
- First think clicked开发者_StackOverflow社区 is that storing CSS as XML will help me read CSS and understand.
- Second is that using XSLT i will be able to generate the CSS (am i right ? will that be useful)
- Lastly when user changed the CSS XML file can be updated and then it can be used.
Now this is at very rough level ..... i am using ASP.NET can some one please guide me if my understanding is correct or not and how should i approach for this pros/cons.
Will something like below will work ? is possible?
<link src="someserverfiletoprocessxmlusingxslt.aspx?user=id" type=text/css/>
That is possible; your ASPX page would need to return CSS with a MIME type of text/css
.
However, it would be better to use an ASHX (Generic Handler) rather than an ASPX (Web Form).
Using an ASP.NET generic HTTP handlers (ashx) would be better. This is just a class that gives you access to the output stream (better for non-html output).
From there you can process the XML, transform it using XSLT and write/dump it on the output stream.
Might be a good idea to implement some kind of caching to enhance performance...
More info on generic handlers: http://www.brainbell.com/tutorials/ASP/Generic_Handlers_(ASHX_Files).html
Setting the method
attribute of the xsl:output
element to text
will strip the resulting output of all XML tags and return it unencoded.
精彩评论