I want to search for content in a CSS file. The XPath/XQuery language is convenient for searching content in XML. How can I find an equivalent so that complex searches in CSS are easy?
Related
While CSS could only set styling and mainly used with HTML. I think it should be possible to use a concept of selector and cascading to apply value to xml attribute
Is there any standardized or proposed syntax for this kind of concept?
It sounds like you're imagining one file which contains an XML document, and another file which contains blocks of properties with values, each block starting with a "selector" of some sort which defines to which XML elements those properties apply (much like CSS, potentially even using the same syntax). Then you are imagining a process which transforms the XML document by modifying the selected XML elements' attributes based on the properties declared for that selector.
The general concept of transforming XML based on a supplementary ruleset is called Extensible Stylesheet Language Transformation (XSLT).
More specifically related to defining properties with selectors and a CSS-like syntax, the World Wide Web Consortium has published "Associating Style Sheets with XML documents", a W3C Recommendation, in 2010. This document provides recommendations to software developers who are performing XSLT for XML and wish to associate CSS-syntax properties which affect the transformation of elements to whom the selector applies.
The application which is consuming the XML is responsible for implementing support for XML stylesheets in this manner -- it is not a core part of the language. Most modern web browsers can perform XML-to-HTML XSLT and many support XML-stylesheets using the syntax described in the W3C recommendation above. For a similar reason, CSS can also be applied directly to SVG files (which is an XML format) when rendered in the browser.
When working with generic XML, rather than XHTML, the recommended syntax is much simpler, with only rudimentary support for selectors.
The W3C guidelines could be applied to use a CSS-like syntax to define properties applied to selected elements in an XML document, and then implement transformations based on those properties to affect the final XML however you desire. Some XML libraries, especial XSLT implementations, may provide extensible mechanisms to make this easier, but ultimately you will need to implement the transformations yourself.
I think this could work: <?xml-stylesheet type="text/css" href="name_of_css_file.css"?>
Here for more info: GeeksForGeeks>Displaying XML Using CSS.
I'm using Apache FOP library to make a transform from a html + css file to pdf file. To do this process, I use several API's to reach to the final pdf. Firstly, I convert the html file to xml using TagSoup, then I transform xml to xsl-fo using xslt stylesheet for then and last step, I transform the xls-fo generated to pdf file. My problem comes when I view the pdf. I want to apply the same css styles as I apply in the html to the pdf too. I know if there are any way to link or include the css files in the xslt file when I try to do the transform to apply this styles on the final pdf.
I know this question is more theorical than a concrete practical case.
I hope anyone can help me.
Thanks!
I was wondering if there is any kind of software who can read an HTML document within a lot of inline styles and convert all these styles into an external css file.
If it was only one page, i could do it manually. But there are 100 pages.
Anybody an idea?
like someone said, 'there's an app for that'. Here it is: http://www.cssout.com/
Try this online tool CSS Out
Read this Dreamweaver help
You can do it easily with PHP. Either use a regex expression (preg_match) to grab content amongst <style> tags or use DOMDocument class as mentioned here
Get text between HTML tags
I've been trying to figure this one out for a while, is there an type of image or url embedding for CSS or its language derivatives (SASS, LESS etc) that do not use this specific syntax?
url:(foo.png) # with or without quotation
I know that SASS can and does use
asset-url('foo.png', image);
but I am counting this as a match (due to my regular expression formula that this is for)
Specific things that I am looking for would be for instance how HTML handles urls with both href and src, though this is unrelated I would like to use it as an example due to the fact that it utilizes urls in different ways. Thanks for taking a minute to quiz over this one =)
CSS can only reference images by the url() function (even embedded image data is a data url). However, compile to CSS languages like LESS and SASS, are far less straight forward...
asset-url() is not a SASS native function. It's provided by the sass-rails gem, and so only available in the context of a rails application. So asset-url() is a custom function that is provided by a library. And you can even write your own function that abstract away calls to url() behind your own custom mixins.
If you want to find all image URLs referenced in some CSS, they only reliable way to do it is to compile it to CSS and then search through that, because that's the only way you can know for sure. And as a bonus, this approach will work for other CSS preprocessors that you havent written a scanner for, because all you care about is CSS.
i would like to make 'skinnable' a web site written in asp.net...
I explain: for example, i have a 'div' element, and i would like to define a background-color using a variable, not a fixed value.
How can i do ?
Css ? Or other tecniques ?
Thanks
CSS is exactly what your are looking for.
Keep in mind that when writing your classes and ids you should refer to the element semantically. It means you should NOT choose your names depending on the visual representation of the element.
Wrongs:
.blue
boxOnLeft
Goods:
.comments
related
To be able to skin your page, you'll just need to change your css.
Almost all is possible using CSS.
ASP.NET has built-in functionality for Themeing and Skinning:
ASP.NET Themes and Skins - MSDN
You could always roll your own as well. The general idea is that you have a seperate set of CSS for each Theme/Skin and then generate the references dynamically based on what Theme/Skin the user selects.
You might look at .Less and t4 template package for it:
http://haacked.com/archive/2009/12/02/t4-template-for-less-css.aspx
A lot of good notes in the comments of that link as well, including a visual studio addin.
CSS doesn't have programming variable capabilities that you hope to achieve.
However, there is a way to do this with PHP (I know you're looking for .NET solution here, but bear with me)
Basically, you add a line of header text "", save the css with .php extension, and then load the .php in html as css (""). Then you can manipulate variables with PHP.
I don't know anything about .NET, but I believe it should be possible in a similar manner.