tinkerwell / jodd

Automatically exported from code.google.com/p/jodd
0 stars 0 forks source link

jodd.csselly.CSSellyException: Unsupported pseudo class #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. The source code:
        doc.$("cfg:test").each(new JerryFunction() {
            public boolean onNode(Jerry $this, int index) {
                System.out.println($this.$("cfg:node").text());
                return true;
            }
        });

2. The sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<cfg:test xmlns:cfg="http://test" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <cfg:node>This is a text</cfg:node>
</cfg:test>

3. The output:
    jodd.csselly.CSSellyException: Unsupported pseudo class: test
    at jodd.csselly.selector.PseudoClassSelector.lookupPseudoClass(PseudoClassSelector.java:84)
    at jodd.csselly.selector.PseudoClassSelector.<init>(PseudoClassSelector.java:95)
    at jodd.csselly.CssSelector.addPseudoClassSelector(CssSelector.java:124)
    at jodd.csselly.CSSellyLexer.yylex(CSSellyLexer.java:1761)
    at jodd.csselly.CSSelly.parse(CSSelly.java:37)
    at jodd.lagarto.dom.NodeSelector.select(NodeSelector.java:38)
    at jodd.jerry.Jerry.find(Jerry.java:282)
    at jodd.jerry.Jerry.$(Jerry.java:290)
    at etri.lsm.check.ACS.checkWorkflow(ACS.java:146)
    at etri.lsm.check.ACS.check(ACS.java:55)
    at etri.lsm.check.Main.main(Main.java:39)

What is the expected output? What do you see instead?

    I want to get "This is a text". But there arises an exception.

What version of the product are you using? On what operating system?

    Jodd-3.4.0

Please provide any additional information below.

    Does jodd-jerry support namespace scoping?

Original issue reported on code.google.com by doosi...@gmail.com on 26 Oct 2012 at 5:36

GoogleCodeExporter commented 9 years ago
Hey Kim,

thank you submitting the issue! We are aware of it; let me explain in more 
details:

+ Lagarto and LagartoDom (parsers behind Jerry) parses tags with namespaces 
correctly, so in your example you will have nodes "cfg:test" and "cfg:nodes". 
You can also see this in example:

https://github.com/oblac/jodd/commit/a67ce89e0db78fc0be267474de141d4b0543c88f

+ Jerry itself doesn't have any influence on this.

+ However, the problem is with CSSelly, our CSS selector engine. The "cfg:test" 
is understood as tag "cfg" and pseudo class "test".

We are aware of this and already started looking for most convenient solution 
for this use case:) We tried first to make Lagarto and Jerry to work with HTML 
content, so now it's time to improve XML parsing support;)

Stay tuned!

Original comment by i...@jodd.org on 26 Oct 2012 at 10:51

GoogleCodeExporter commented 9 years ago
Fixed by this commit:

https://github.com/oblac/jodd/commit/d05eaf47edceaf1333ac07753acb65b6febd8075

Your usecase should looks like in jquery:

jerry.$("cfg\\:test").each(new JerryFunction() {
    public boolean onNode(Jerry $this, int index) {
        result.append($this.$("cfg\\:node").text());
        return true;
    }
});

I will start to upload changes to the site and to publish snapshot.

Original comment by i...@jodd.org on 26 Oct 2012 at 5:23

GoogleCodeExporter commented 9 years ago
Thank you. Your update is exactly what I need.

I wish you have a good day.

Good Bye.

2012년 10월 27일 토요일에 님이 작성:

Original comment by doosi...@gmail.com on 26 Oct 2012 at 5:28