Package org.milyn.cdr.xpath

Examples of org.milyn.cdr.xpath.SelectorStep


    private XMLSerializationNode constructNodePath(SelectorStep[] selectorSteps, List<XMLElementSerializationNode> graphRoots) {
        if(selectorSteps == null || selectorSteps.length == 0) {
            throw new IllegalStateException("Invalid binding configuration.  All <jb:bean> configuration elements must specify fully qualified selector paths (createOnElement, data, executeOnElement attributes etc.).");
        }

        SelectorStep rootSelectorStep = selectorSteps[0];
        XMLElementSerializationNode root = XMLElementSerializationNode.getElement(rootSelectorStep, graphRoots, true);

        if(selectorSteps.length > 1) {
            return root.getPathNode(selectorSteps, 1, true);
        } else if(rootSelectorStep.getTargetAttribute() != null) {
            // It's an attribute node...
            return XMLElementSerializationNode.addAttributeNode(root, rootSelectorStep, true);
        } else {
            return root;
        }
View Full Code Here


    public XMLSerializationNode getPathNode(SelectorStep[] selectorSteps, int stepIndex, boolean create) {
        if(stepIndex >= selectorSteps.length) {
            throw new IllegalStateException("Unexpected call to 'addPathNode'.  SelectorStep index out of bounds.");
        }

        SelectorStep selectorStep = selectorSteps[stepIndex];

        if(stepIndex == selectorSteps.length - 1 && selectorStep.getTargetAttribute() != null) {
            // It's an attribute node...
            XMLElementSerializationNode elementNode = getElement(selectorStep, elements, create);
            return addAttributeNode(elementNode, selectorStep, create);
        } else {
            // It's an element...
View Full Code Here

                        configList = XMLConfigDigester.digestConfig(bindingSource.getByteStream(), "./", extendedConfigDigesters, classloader);
                        for(int i = 0; i < configList.size(); i++) {
                            SmooksResourceConfiguration config = configList.get(i);
                           
                            if(config.getSelectorNamespaceURI() == null) {
                                SelectorStep selectorStep = config.getSelectorStep();

                                // And if there isn't a namespace prefix specified on the element (unresolved at this point),
                                // then assign the binding config namespace...
                                if(selectorStep.getTargetElement().getPrefix().equals(XMLConstants.DEFAULT_NS_PREFIX)) {
                                    config.setSelectorNamespaceURI(namespace.uri);
                                }
                            }
                        }
                    } catch (URISyntaxException e) {
View Full Code Here

        } else if (selectorSteps[index.i].isStarStar()) {
            if(index.i == 0) {
                // No more tokens to match and ** matches everything
                return true;
            } else if(index.i == 1) {
                SelectorStep parentStep = selectorSteps[index.i - 1];

                if(parentElement == null && parentStep.isRooted()) {
                    // we're at the root of the document and the only selector left is
                    // the document selector.  Pass..
                    return true;
                } else
                  if(parentElement == null) {
                    // we're at the root of the document, yet there are still
                    // unmatched tokens in the selector.  Fail...
                    return false;
                }
            } else if(parentElement == null) {
                // we're at the root of the document, yet there are still
                // unmatched tokens in the selector.  Fail...
                return false;
            }

            SelectorStep parentStep = selectorSteps[index.i - 1];

            if(parentStep.isTargetedAtElement(parentElement)) {
                if(!parentStep.isStarStar()) {
                    XPathExpressionEvaluator evaluator = parentStep.getPredicatesEvaluator();
                    if(evaluator == null) {
                        logger.debug("Predicate Evaluators for resource [" + this + "] is null.  XPath step predicates will not be evaluated.");
                    } else if(!evaluator.evaluate(parentElement, index.executionContext)) {
                        return false;
                    }
View Full Code Here

        } else if (selectorSteps[index.i].isStarStar()) {
            if(index.i == 0) {
                // No more tokens to match and ** matches everything
                return true;
            } else if(index.i == 1) {
                SelectorStep parentStep = selectorSteps[index.i - 1];

                if(parentElement == null && parentStep.isRooted()) {
                    // we're at the root of the document and the only selector left is
                    // the document selector.  Pass..
                    return true;
                } else
                  if(parentElement == null) {
                    // we're at the root of the document, yet there are still
                    // unmatched tokens in the selector.  Fail...
                    return false;
                }
            } else if(parentElement == null) {
                // we're at the root of the document, yet there are still
                // unmatched tokens in the selector.  Fail...
                return false;
            }

            SelectorStep parentStep = selectorSteps[index.i - 1];

            if(parentStep.isTargetedAtElement(parentElement)) {
                if(!parentStep.isStarStar()) {
                    XPathExpressionEvaluator evaluator = parentStep.getPredicatesEvaluator();
                    if(evaluator == null) {
                        logger.debug("Predicate Evaluators for resource [" + this + "] is null.  XPath step predicates will not be evaluated.");
                    } else if(!evaluator.evaluate(parentElement, index.executionContext)) {
                        return false;
                    }
View Full Code Here

        Collection<List<ContentHandlerConfigMap<? extends SAXVisitor>>> contentHandlerMaps = table.values();

        for(List<ContentHandlerConfigMap<? extends SAXVisitor>> contentHandlerMapList : contentHandlerMaps) {
            for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : contentHandlerMapList) {
                SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig();
                SelectorStep selectorStep = resourceConfig.getSelectorStep();

                if(selectorStep.accessesText()) {
                    throw new SmooksConfigurationException("Unsupported selector '" + selectorStep.getXPathExpression() + "' on resource '" + resourceConfig + "'.  The 'text()' XPath token is only supported on SAX Visitor implementations that implement the " + SAXVisitAfter.class.getName() + " interface only.  Class '" + resourceConfig.getResource() + "' implements other SAX Visitor interfaces.");
                }
            }
        }
    }
View Full Code Here

            }
        }
    }

    private void addIndexCounter(ElementIndexCounter indexCounter) {
        SelectorStep selectorStep = indexCounter.getSelectorStep();
        QName targetElement = selectorStep.getTargetElement();
        String targetElementName = targetElement.getLocalPart();
        String targetNS = targetElement.getNamespaceURI();
        SAXElementVisitorMap visitorMap = optimizedVisitorConfig.get(targetElementName);

        if(visitorMap == null) {
View Full Code Here

        if(visitAfters == null) {
            return;
        }
        for(ContentHandlerConfigMap<? extends SAXVisitor> contentHandlerMap : visitAfters) {
            SmooksResourceConfiguration resourceConfig = contentHandlerMap.getResourceConfig();
            SelectorStep selectorStep = resourceConfig.getSelectorStep();

            if(selectorStep.accessesText()) {
                accumulateText = true;
                break;
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.milyn.cdr.xpath.SelectorStep

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.