Description Usage Arguments Value Author(s) References See Also Examples
This is the function that allows us to lookup/resolve
the CSS element that would apply to a particular XML/HTML
element. We can take XML nodes created using the
XML
package.
1 | getCSSRules(nodes, sheet, eng = NULL)
|
nodes |
an object of class |
sheet |
the |
eng |
the CSS selection engine. This can be created once and used in multiple, separate calls to this function. This will improve performance marginally. |
A list of CSSStatement
objects.
Duncan Temple Lang
libcroco at http://www.freespiders.org/projects/libcroco Cascading Style Sheets http://www.w3.org/Style/CSS/
readCSS
xmlParse
, getNodeSet
, newXMLNode
asCSSObject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | css = readCSS( system.file("samples", "OmegaTech.css", package = "RCSS"))
if(require(XML)) {
b = newXMLNode("BODY")
code = newXMLNode("code", attrs = c(class = "r"))
rules = getCSSRules(b, css)
x = asCSSObject(rules[[1]])
}
if(require(XML)) {
css = readCSS( system.file("samples", "descendant.css", package = "RCSS"))
node = newXMLNode("a", newXMLNode("b", newXMLNode("c", "some text")))
# nothing matches the top-level node "a"
getCSSRules(node, css)
# for b we get the match a > b
r = getCSSRules(node[[1]], css)
asCSSObject(r[[1]])
# a c
r = getCSSRules(node[[1]][[1]], css)
asCSSObject(r[[1]])
# All the nodes in a document.
doc = newXMLDoc(node = node, addFinalizer = FALSE)
allNodes = getNodeSet(doc, "//*")
lapply(allNodes, getCSSRules, css)
# We can create the selection engine just once
eng = .Call("R_createSelectionEngine")
lapply(allNodes, getCSSRules, css, eng)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.