server-side css selectors(服务器端 CSS 选择器)
问题描述
我正在创建一个工具,它将检查动态生成的 XHTML 并根据预期内容对其进行验证.
I am creating a tool that will check dynamically generated XHTML and validate it against expected contents.
我需要确认结构正确且特定属性存在/匹配.可能还有其他我不感兴趣的属性,所以直接字符串比较是不合适的.
I need to confirm the structure is correct and that specific attributes exist/match. There may be other attributes which I'm not interested in, so a direct string comparison is not suitable.
验证这一点的一种方法是使用 XPath,我已经实现了这一点,但我还想要一些不那么冗长的东西 - 我希望能够使用 CSS 选择器,就像我可以使用 jQuery 一样,但在服务器上 - 在CFML 代码 - 而不是在客户端上.
One way of validating this is with XPath, and I have implemented this already, but I would also like something less verbose - I want to be able to use CSS Selectors, like I can with jQuery, but on the server - within CFML code - as opposed to on the client.
是否有 CFML 或 Java 库允许我针对 XHTML 字符串使用 CSS 选择器?
推荐答案
我刚刚发布了一个开源项目,它是 Java 中的 W3C CSS Selectors Level 3 实现.请试一试.我一直在寻找同样的东西,并决定实现我自己的引擎.它的灵感来自 WebKit 等中的代码.
I've just released an open source project which is a W3C CSS Selectors Level 3 implementation in Java. Please give it a try. I was looking for the same thing and decided to implement my own engine. It's inspired by the code in WebKit etc.
http://github.com/chrsan/css-selectors/tree
这篇关于服务器端 CSS 选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:服务器端 CSS 选择器
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
