The link pseudo-classes :link and :visited can not be supported because they refer to a DOM model.
The dynamic pseudo-classes :hover, :active, and :focus can not be supported because they require user input.
The pseudo-elements :first-line, :first-letter, :before, and :after can not be supported because they do not select XML elements.
Quick Start
1). Create a text file called Example.fan:
using afSizzle
class Example {
Void main() {
xml := """<html><p class="welcome">Hello from Sizzle!</p></html>"""
elems := Sizzle().selectFromStr(xml, "p.welcome")
echo(elems.first.text) // -> Hello from Sizzle!
}
}
2). Run Example.fan as a Fantom script from the command line:
C:\> fan Example.fan
Hello from Sizzle!
Why?
Sizzle was created primarily for querying (X)HTML documents and web pages for testing web applications.
Lemme know if you have any problems.
Have fun!
brianFri 10 Jan 2014
This is cool, I had ambitions of adding XPath into the core xml APIs. But find I actually don't do much XML these days so never got around to id. CSS selector is an interesting approach too - maybe even better approach than XPath (at least more known). For people out doing XML, what sort of selection APIs are popular these days?
SlimerDudeFri 10 Jan 2014
I don't know of any other XML selection standards other than XPath and CSS. For instance, Capybara (a popular Ruby testing framework) only supports these two.
XPath always has been the XML selection standard, but it's always seemed large and cumbersome (in both the specification and reference implementations!). By comparison, for testing web apps, CSS has always (seemed to me) a lighter and more natural alternative.
I see them as serving 2 different problem spaces; XPath for information documents, and CSS for visual HTML documents. The 2 documents have very different structures and, hence, require 2 different selection mechanisms.
Anyone who's tried to select a class with XPath knows this! For example:
SlimerDude Thu 9 Jan 2014
Sizzle v0.0.6 Released!
Sizzle is a library for querying XML documents by means of CSS 2.1 selectors.
fanr install -r http://repo.status302.com/fanr/ afSizzle
Overview
Sizzle
currently supports:*
div
#id
.heading
html div
html > div
div + p
[att]
[att=val]
[att~=val]
[att|=val]
:first-child
:lang(xxx)
The following selectors can not be supported:
:link
and:visited
can not be supported because they refer to a DOM model.:hover
,:active
, and:focus
can not be supported because they require user input.:first-line
,:first-letter
,:before
, and:after
can not be supported because they do not select XML elements.Quick Start
1). Create a text file called
Example.fan
:2). Run
Example.fan
as a Fantom script from the command line:Why?
Sizzle
was created primarily for querying (X)HTML documents and web pages for testing web applications.Lemme know if you have any problems.
Have fun!
brian Fri 10 Jan 2014
This is cool, I had ambitions of adding XPath into the core xml APIs. But find I actually don't do much XML these days so never got around to id. CSS selector is an interesting approach too - maybe even better approach than XPath (at least more known). For people out doing XML, what sort of selection APIs are popular these days?
SlimerDude Fri 10 Jan 2014
I don't know of any other XML selection standards other than XPath and CSS. For instance, Capybara (a popular Ruby testing framework) only supports these two.
XPath always has been the XML selection standard, but it's always seemed large and cumbersome (in both the specification and reference implementations!). By comparison, for testing web apps, CSS has always (seemed to me) a lighter and more natural alternative.
I see them as serving 2 different problem spaces; XPath for information documents, and CSS for visual HTML documents. The 2 documents have very different structures and, hence, require 2 different selection mechanisms.
Anyone who's tried to select a class with XPath knows this! For example:
XPath would be cool, but the specification is too bloated for (the likes of) me to tackle!