Package client.net.sf.saxon.ce.trans

Examples of client.net.sf.saxon.ce.trans.Rule


    public byte isSpacePreserving(int fingerprint) throws XPathException {
        if (preserveAll) {
            return ALWAYS_PRESERVE;
        }

        Rule rule = stripperMode.getRule(fingerprint);

        if (rule==null) {
            return ALWAYS_PRESERVE;
        }

        return (rule.getAction() == PRESERVE ? ALWAYS_PRESERVE : STRIP_DEFAULT);

    }
View Full Code Here


        // handle parameters if any

        ParameterSet params = assembleParams(context, actualParams);
        ParameterSet tunnels = assembleTunnelParams(context, tunnelParams);

        Rule currentRule = context.getCurrentTemplateRule();
        if (currentRule==null) {
            XPathException e = new XPathException("There is no current template rule");
            e.setXPathContext(context);
            e.setErrorCode("XTDE0560");
            throw e;
        }
        Mode mode = context.getCurrentMode();
        if (mode == null) {
            mode = controller.getRuleManager().getUnnamedMode();
        }
        if (context.getCurrentIterator()==null) {
            XPathException e = new XPathException("There is no context item");
            e.setXPathContext(context);
            e.setErrorCode("XTDE0565");
            throw e;
        }
        Item currentItem = context.getCurrentIterator().current();
        if (!(currentItem instanceof NodeInfo)) {
            XPathException e = new XPathException("Cannot call xsl:next-match when context item is not a node");
            e.setXPathContext(context);
            e.setErrorCode("XTDE0565");
            throw e;
        }
        NodeInfo node = (NodeInfo)currentItem;
        Rule rule = controller.getRuleManager().getNextMatchHandler(node, mode, currentRule, context);

    if (rule==null) {             // use the default action for the node
            mode.getBuiltInRuleSet().process(node, params, tunnels, context, getSourceLocator());
        } else if (useTailRecursion) {
            //Template nh = (Template)rule.getAction();
            // clear all the local variables: they are no longer needed
            Arrays.fill(context.getStackFrame().getStackFrameValues(), null);
            return new NextMatchPackage(rule, params, tunnels, context);
        } else {
            Template nh = rule.getAction();
            XPathContextMajor c2 = context.newContext();
            c2.openStackFrame(nh.getStackFrameMap());
            c2.setLocalParameters(params);
            c2.setTunnelParameters(tunnels);
            c2.setCurrentTemplateRule(rule);
View Full Code Here

        // handle parameters if any

        ParameterSet params = assembleParams(context, actualParams);
        ParameterSet tunnels = assembleTunnelParams(context, tunnelParams);

        Rule currentTemplateRule = context.getCurrentTemplateRule();
        if (currentTemplateRule==null) {
            dynamicError("There is no current template rule", "XTDE0560", context);
        }

        int min = currentTemplateRule.getMinImportPrecedence();
        int max = currentTemplateRule.getPrecedence()-1;
        Mode mode = context.getCurrentMode();
        if (mode == null) {
            mode = controller.getRuleManager().getUnnamedMode();
        }
        if (context.getCurrentIterator()==null) {
            dynamicError("Cannot call xsl:apply-imports when there is no context item", "XTDE0565", context);
        }
        Item currentItem = context.getCurrentIterator().current();
        if (!(currentItem instanceof NodeInfo)) {
            dynamicError("Cannot call xsl:apply-imports when context item is not a node", "XTDE0565", context);
        }
        NodeInfo node = (NodeInfo)currentItem;
        Rule rule = controller.getRuleManager().getTemplateRule(node, mode, min, max, context);

    if (rule==null) {             // use the default action for the node
            mode.getBuiltInRuleSet().process(node, params, tunnels, context, getSourceLocator());
        } else {
            XPathContextMajor c2 = context.newContext();
            Template nh = (Template)rule.getAction();
            c2.setLocalParameters(params);
            c2.setTunnelParameters(tunnels);
            c2.openStackFrame(nh.getStackFrameMap());
            c2.setCurrentTemplateRule(rule);
            nh.apply(c2);
View Full Code Here

       
        // walk up the tree until we find an element with matching rule for the event mode

        NodeInfo element = eventNode;
          while (element != null) {
              Rule matchedRule = matchedMode.getRule(element, ruleContext);
              if (matchedRule != null && eventPropertyMatch(event, matchedRule)) {
                logger.log(Level.FINER, "Bubble Apply-Templates - Mode: " + matchedMode.getModeName().getLocalName() +
                    " Element: " + controller.getNamePool().getLocalName(element.getNameCode()));
                applyEventTemplates(matchedMode.getModeName().getClarkName(), element, event, null);
                if (matchedRule.getIxslPreventDefault()) {
                  event.preventDefault();
                }
                break;
              }
              element = (NodeInfo)bubbleElements.next();
View Full Code Here

                break;
            }

            // find the template rule for this node

            Rule rule = mode.getRule(node, context);
            if (rule==null) {
              rule = mode.getVirtualRule(context);
            }

            if (rule==null) {
              // Use the default action for the node
                // No need to open a new stack frame!
                mode.getBuiltInRuleSet().process(node, parameters, tunnelParameters, context, sourceLocator);
            } else {
                Template template = (Template)rule.getAction();
                if (template != previousTemplate) {
                    // Reuse the previous stackframe unless it's a different template rule
                    previousTemplate = template;
                    context.openStackFrame(template.getStackFrameMap());
                    context.setLocalParameters(parameters);
                    context.setTunnelParameters(tunnelParameters);
                }
                context.setCurrentTemplateRule(rule);
                if (rule.isVirtual()){
                  SequenceIterator iter = IXSLFunction.convertFromJavaScript(context.getController().getUserData("Saxon-CE", "current-object"),
                      context.getConfiguration());
                  iter.next(); // position on the item;
                    context.setCurrentIterator(iter);
                }
View Full Code Here

TOP

Related Classes of client.net.sf.saxon.ce.trans.Rule

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.