Package net.sf.saxon.expr

Examples of net.sf.saxon.expr.PathExpression


        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = DOMUtils.toDOMDocument(contextNode);
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);

                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }

                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }

                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                        attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                        ((Element) contextNode).setAttributeNode(attribute);
                        contextNode = attribute;
                    } else {
                        break;
                    }

                } else {
                    break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                }
            } else {
View Full Code Here


        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = DOMUtils.toDOMDocument(contextNode);
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);
               
                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                 
                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                   
                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                      attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                      ((Element) contextNode).setAttributeNode(attribute);
                      contextNode = attribute;
                    } else {
                      break;
                    }
                 
                } else {
                  break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                }
            } else {
View Full Code Here

        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = contextNode.getOwnerDocument();
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);

                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }

                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }

                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                        attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                        ((Element) contextNode).setAttributeNode(attribute);
                        contextNode = attribute;
                    } else {
                        break;
                    }

                } else {
                    break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                } else {
                    throw new RuntimeException("Not supported step " + remainingSteps + " in expression " + expression);
View Full Code Here

        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = DOMUtils.toDOMDocument(contextNode);
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);
               
                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                 
                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                   
                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                      attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                      ((Element) contextNode).setAttributeNode(attribute);
                      contextNode = attribute;
                    } else {
                      break;
                    }
                 
                } else {
                  break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                } else {
                    throw new RuntimeException("Not supported step " + remainingSteps + " in expression " + expression);
View Full Code Here

        if (!(subExpr instanceof PathExpression)) {
            return;
        }

        Document document = DOMUtils.toDOMDocument(contextNode);
        PathExpression pathExpr = (PathExpression) subExpr;
        Expression step = pathExpr.getFirstStep();

        while (step != null) {
            if (step instanceof AxisExpression) {
                AxisExpression axisExpr = (AxisExpression) step;

                NodeTest nodeTest = axisExpr.getNodeTest();

                if (!(nodeTest instanceof NameTest)) {
                    break;
                }

                NameTest nameTest = (NameTest) nodeTest;

                QName childName = getQualifiedName(nameTest.getFingerprint(),
                        namePool, contextUris);
               
                if (Axis.CHILD == axisExpr.getAxis()) {
                    if (NodeKindTest.ELEMENT.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                 
                    NodeList children = ((Element) contextNode).getElementsByTagNameNS(childName.getNamespaceURI(),
                            childName.getLocalPart());
                    if ((children == null) || (children.getLength() == 0)) {
                        Node child = document.createElementNS(childName.getNamespaceURI(),
                                DOMUtils.getQualifiedName(childName));
                        contextNode.appendChild(child);
                        contextNode = child;
                    } else if (children.getLength() == 1) {
                        contextNode = children.item(0);
                    } else {
                        break;
                    }
                } else if (Axis.ATTRIBUTE == axisExpr.getAxis()) {
                    if (NodeKindTest.ATTRIBUTE.getNodeKindMask() != nameTest.getNodeKindMask()) {
                        break;
                    }
                   
                    Attr attribute = ((Element) contextNode).getAttributeNodeNS(childName.getNamespaceURI(), childName.getLocalPart());
                    if (attribute == null) {
                      attribute = document.createAttributeNS(childName.getNamespaceURI(), childName.getLocalPart());
                      ((Element) contextNode).setAttributeNode(attribute);
                      contextNode = attribute;
                    } else {
                      break;
                    }
                 
                } else {
                  break;
                }


            } else if (step instanceof ItemChecker) {
                ItemChecker itemChecker = (ItemChecker) step;
                Expression baseExpr = itemChecker.getBaseExpression();

                if (!(baseExpr instanceof VariableReference)) {
                    break;
                }
            } else {
                break;
            }

            if (pathExpr != null) {
                Expression remainingSteps = pathExpr.getRemainingSteps();

                if (remainingSteps instanceof PathExpression) {
                    pathExpr = (PathExpression) remainingSteps;
                    step = pathExpr.getFirstStep();
                } else if (remainingSteps instanceof AxisExpression) {
                    pathExpr = null;
                    step = (AxisExpression) remainingSteps;
                }
            } else {
View Full Code Here

TOP

Related Classes of net.sf.saxon.expr.PathExpression

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.