Search in sources :

Example 6 with SimpleElementSelector

use of org.asqatasun.rules.elementselector.SimpleElementSelector in project Asqatasun by Asqatasun.

the class Aw22Rule10012 method select.

@Override
protected void select(SSPHandler sspHandler) {
    totalNumberOfElements = sspHandler.getTotalNumberOfElements();
    // retrieve element from the nomenclature
    Nomenclature deprecatedHtmlAttr = nomenclatureLoaderService.loadByCode(PRESENTATION_ATTR_NOM);
    for (String deprecatedAttr : deprecatedHtmlAttr.getValueList()) {
        SimpleElementSelector sec = new SimpleElementSelector(buildQuery(deprecatedAttr));
        ElementHandler<Element> eh = new ElementHandlerImpl();
        sec.selectElements(sspHandler, eh);
        attrElementHandlerMap.put(deprecatedAttr, eh);
    }
    // elements with width attribute that are not img
    SimpleElementSelector secWidthAttrNotImg = new SimpleElementSelector(ELEMENT_WITH_WITDH_ATTR_NOT_IMG);
    ElementHandler<Element> ehWithAttrNotImg = new ElementHandlerImpl();
    secWidthAttrNotImg.selectElements(sspHandler, ehWithAttrNotImg);
    attrElementHandlerMap.put(WIDTH_ATTR, ehWithAttrNotImg);
    // elements with width attribute that are not img
    SimpleElementSelector secHeightAttrNotImg = new SimpleElementSelector(ELEMENT_WITH_HEIGHT_ATTR_NOT_IMG);
    ElementHandler<Element> ehHeightAttrNotImg = new ElementHandlerImpl();
    secHeightAttrNotImg.selectElements(sspHandler, ehHeightAttrNotImg);
    attrElementHandlerMap.put(HEIGHT_ATTR, ehHeightAttrNotImg);
}
Also used : Nomenclature(org.asqatasun.entity.reference.Nomenclature) Element(org.jsoup.nodes.Element) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector)

Example 7 with SimpleElementSelector

use of org.asqatasun.rules.elementselector.SimpleElementSelector in project Asqatasun by Asqatasun.

the class Aw22Rule08091 method select.

@Override
protected void select(SSPHandler sspHandler) {
    // Selection of all links without target
    ElementSelector linkWithoutTargetSelector = new SimpleElementSelector(LINK_WITHOUT_TARGET_CSS_LIKE_QUERY);
    linkWithoutTargetSelector.selectElements(sspHandler, linkWithoutTarget);
    // Selection of all links without target
    ElementSelector fielsetNotWithinFormSelector = new SimpleElementSelector(FIELDSET_NOT_WITHIN_FORM_CSS_LIKE_QUERY);
    fielsetNotWithinFormSelector.selectElements(sspHandler, fieldsetNotWithinForm);
    totalNumberOfElements = sspHandler.getTotalNumberOfElements();
}
Also used : SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector) ElementSelector(org.asqatasun.rules.elementselector.ElementSelector) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector)

Example 8 with SimpleElementSelector

use of org.asqatasun.rules.elementselector.SimpleElementSelector in project Asqatasun by Asqatasun.

the class Rgaa22Rule07081 method select.

@Override
protected void select(SSPHandler sspHandler) {
    super.select(sspHandler);
    // retrieve element from the nomenclature
    Nomenclature deprecatedHtmlTags = nomenclatureLoaderService.loadByCode(PRESENTATION_TAG_NOM);
    // add each element of the nomenclature to the selector
    MultipleElementSelector mes = new MultipleElementSelector();
    for (String deprecatedTag : deprecatedHtmlTags.getValueList()) {
        mes.addCssQuery(deprecatedTag.toLowerCase());
    }
    mes.selectElements(sspHandler, deprecatedElementHandler);
    // retrieve element from the nomenclature
    Nomenclature deprecatedHtmlAttr = nomenclatureLoaderService.loadByCode(PRESENTATION_ATTR_NOM);
    for (String deprecatedAttr : deprecatedHtmlAttr.getValueList()) {
        SimpleElementSelector sec = new SimpleElementSelector(buildQuery(deprecatedAttr));
        ElementHandler eh = new ElementHandlerImpl();
        sec.selectElements(sspHandler, eh);
        attrElementHandlerMap.put(deprecatedAttr, eh);
    }
}
Also used : Nomenclature(org.asqatasun.entity.reference.Nomenclature) ElementHandlerImpl(org.asqatasun.ruleimplementation.ElementHandlerImpl) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector) ElementHandler(org.asqatasun.ruleimplementation.ElementHandler) MultipleElementSelector(org.asqatasun.rules.elementselector.MultipleElementSelector)

Example 9 with SimpleElementSelector

use of org.asqatasun.rules.elementselector.SimpleElementSelector in project Asqatasun by Asqatasun.

the class Rgaa22Rule07091 method select.

@Override
protected void select(SSPHandler sspHandler) {
    // Selection of all links without target
    ElementSelector linkWithoutTargetSelector = new SimpleElementSelector(LINK_WITHOUT_TARGET_CSS_LIKE_QUERY);
    linkWithoutTargetSelector.selectElements(sspHandler, linkWithoutTarget);
    // Selection of all links without target
    ElementSelector fielsetNotWithinFormSelector = new SimpleElementSelector(FIELDSET_NOT_WITHIN_FORM_CSS_LIKE_QUERY);
    fielsetNotWithinFormSelector.selectElements(sspHandler, fieldsetNotWithinForm);
    totalNumberOfElements = sspHandler.getTotalNumberOfElements();
}
Also used : SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector) ElementSelector(org.asqatasun.rules.elementselector.ElementSelector) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector)

Example 10 with SimpleElementSelector

use of org.asqatasun.rules.elementselector.SimpleElementSelector in project Asqatasun by Asqatasun.

the class SeoRule07051 method select.

@Override
protected void select(SSPHandler sspHandler) {
    ElementSelector selector = new SimpleElementSelector(H1_ELEMENT);
    selector.selectElements(sspHandler, h1Elements);
    // only keep one title when more than 2 are encountered
    selector = new SimpleElementSelector(TITLE_ELEMENT);
    selector.selectElements(sspHandler, titleElement);
    if (titleElement.get().size() > 1) {
        Element title = titleElement.get().iterator().next();
        titleElement.clean().add(title);
    }
}
Also used : Element(org.jsoup.nodes.Element) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector) ElementSelector(org.asqatasun.rules.elementselector.ElementSelector) SimpleElementSelector(org.asqatasun.rules.elementselector.SimpleElementSelector)

Aggregations

SimpleElementSelector (org.asqatasun.rules.elementselector.SimpleElementSelector)28 ElementSelector (org.asqatasun.rules.elementselector.ElementSelector)16 Element (org.jsoup.nodes.Element)13 ElementHandlerImpl (org.asqatasun.ruleimplementation.ElementHandlerImpl)9 Nomenclature (org.asqatasun.entity.reference.Nomenclature)4 InputFormElementWithExplicitLabelSelector (org.asqatasun.rules.elementselector.InputFormElementWithExplicitLabelSelector)4 InputFormElementWithInplicitLabelSelector (org.asqatasun.rules.elementselector.InputFormElementWithInplicitLabelSelector)3 TestSolution (org.asqatasun.entity.audit.TestSolution)1 ElementHandler (org.asqatasun.ruleimplementation.ElementHandler)1 CompositeLinkElementSelector (org.asqatasun.rules.elementselector.CompositeLinkElementSelector)1 LinkElementSelector (org.asqatasun.rules.elementselector.LinkElementSelector)1 MultipleElementSelector (org.asqatasun.rules.elementselector.MultipleElementSelector)1