-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate using Fizzle for selection in HTML Blobs #18
Comments
OK. So FlowQuery uses Fizzle in the Filter operation, as I expected. It passes the argument string into fizzle, and gets an array (a syntax tree) back. Fizzle already has support for the See |
I'll probably use matchesPropertyNameFilter() to filter the tag name, I think. The only issue is, I might want to get a namespaced tag (to select a fluid tag like So, I might have to extend ObjectIdentifier to be Speaking of the colon, in BlobQuery, I'm going to want to filter based on |
In the attribute Filter Then again, could I use the propertyNameFilter to get the class definition? So It is also possible to use symfony/CssSelector instead of Fizzle, but I'd really like to avoid adding another dependency. Hopefully fizzle will work. |
So the propertyNameFilter expects an identifier which is defined as: And the only place that it looks for a property path is in the attribute filter, but it doesn't match a period |
The docs[1] say that 'foo.bar.baz' would be a valid property name, but the parser grammar doesn't accept periods in property names[2]. Plus, there are no unit tests that include a period in the property name[3], even though there are some method stubs in filter() that seem to expect that a propertyName can include periods. (2) The grammar expects an Identifier (3) https://git.typo3.org/Packages/TYPO3.Eel.git/blob/HEAD:/Tests/Unit/FlowQuery/FizzleParserTest.php#l68 |
So, I would have to do some major voodoo with Fizzle to get it to understand tag#id.class Maybe I should just bite the bullet and include symfony\CssSelector and then implement a new filter() operation that is only used for HTML, but takes the css selector and passes it on to DomCrawler to get the right spot in the file. |
symfony\DomCrawler isn't really the best tool for generating HTML. It's designed to retrieve and navigate it, so that you can submit forms, but I would have to build a bunch of stuff around it to make it work the way I need it to (read and write html files, as well as the html in fluid files). Other options include:
My requirements include:
|
TemplaVoila suffers from NIH-syndrome. There's are elements of CSS selectors (like #id and .class) but it uses a custom [number] annotation that is unique to TemplaVoila, as well as the keywords INNER and OUTER to see whether or not to include a matched tag. I really don't want to go down the same path as TemplaVoila, and contorting Fizzle to select HTML elements would do exactly that. No, I will use an external library, and I will use standard XPath and/or CSS Selectors. The question is, is there an equivalent to INNER/OUTER in CSS or in XPath? |
CSS Selctors can select elements but not the contents of those elements. The closest we get to selecting the contents of an element is I will want something like before and after, but I think I need even more power. So, to map TV concepts onto XPath:
|
Just to follow up. I investigated the various parsers mentioned earlier and QueryPath is the best for what I need. It's faster than SimpleHTMLDOM[1], is designed for editing unlike DomCrawler[2], and is more actively maintained that PhpQuery and in 2010 it was faster than PhpQuery at write operations[3]. Also, support for HTML5 (and especially HTML5 fragments) is underway in QueryPath 3.x, so it really is the best choice. That means that, for the most part, CSS Selectors are the way to go for selecting elements in the docs. I can use xpath if needed, and maybe someone will add an xquery operation at some point, but for now, CSS Selectors through QueryPath is what I'm going to use. [1] https://groups.google.com/forum/#!topic/support-querypath/DEQIsoZW_pU |
In HTML Blobs (typically subBlobs of Fluid Blobs when using the TemplateBuilder, I'm going to need a way to select elements in the syntax tree.
Fizzle is the standard for FlowQuery (which is what I'm using), but it does not have some of the convenience syntax that is so common in Css. The most important of which are:
#id
.class
I guess fizzle properties would map onto tags or elements, but I don't know how that works. I also need to be able to select Blobs based on their package and file path.
Here are some specific things to look into:
tag#id.class
syntax (semantics should depend on the syntax, as this won't make sense everywhere fizzle is used)Cognfiire.EmptyBoilerplate:Resources/Private/FooBar.txt
filter()
operation. (Fizzle is just an argument, right?)foo.bar.baz
I think I'll have to use XPath, but if someone wants to write their own CSS Selector, I'll support that using symfony\CssSelector. For anything a builder writes to a file, unless it is user provided, it will be XPath. Hopefully XPath isn't hard to generate in JavaScript because this selector will be something that will go back and forth between the UI and the backend.
The text was updated successfully, but these errors were encountered: