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

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


            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);
View Full Code Here


            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);
View Full Code Here

            StylesheetModule module = declaration.getModule();
            int slots = match.allocateSlots(getStaticContext(), getSlotManager(), 0);
            RuleManager mgr = getPreparedStylesheet().getRuleManager();
            for (int i=0; i<modeNames.length; i++) {
                StructuredQName nc = modeNames[i];
                Mode mode = mgr.getMode(nc, true);
                if (prioritySpecified) {
                    mgr.setTemplateRule(match, compiledTemplate, mode,
                        module, priority, ixslPreventDefault, ixslEventProperty);
                } else {
                    mgr.setTemplateRule(match, compiledTemplate, mode,
                        module, Double.NaN, ixslPreventDefault, ixslEventProperty);
                }
                mode.allocatePatternSlots(slots);
            }

            allocatePatternSlots(slots);
        }
    }
View Full Code Here

   
    // emulate bubbling up events by iterating through ancestors that have matching rule, starting with the
    // targetNode
   
    private Mode getModeFromEvent(Event event) {
      Mode result = null;
      String mode = "on" + event.getType(); // eg. onclick
      for (Mode m: registeredEventModes){
        if (m.getModeName().getLocalName().equals(mode)) {
          result = m;
          break;
View Full Code Here

      SequenceIterator bubbleElements = eventNode.iterateAxis(Axis.ANCESTOR, NodeKindTest.ELEMENT);
      Controller controller = stylesheet.newTransformer();
      try {
          controller.importControllerSettings(localController);
        XPathContext ruleContext = controller.newXPathContext();
        Mode matchedMode = getModeFromEvent(event);
       
        if (matchedMode == null) {
          return;
        }
       
        // 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;
              }
View Full Code Here

     * Get the current mode.
     * @return the current mode. May return null if the current mode is the default mode.
     */

    public Mode getCurrentMode() {
        Mode m = currentMode;
        if (m == null) {
            RuleManager rm = getController().getRuleManager();
            if (rm != null) {
                return rm.getUnnamedMode();
            } else {
View Full Code Here

                    throw new XPathException("Either a source document or an initial template must be specified");
                }

            } else {

                Mode mode = preparedStylesheet.getRuleManager().getMode(initialMode, false);
                if (mode == null || (initialMode != null && mode.isEmpty())) {
                    throw new XPathException("Requested initial mode " +
                            (initialMode == null ? "" : initialMode.getDisplayName()) +
                            " does not exist", "XTDE0045");
                }

                if (source.getSystemId() != null) {
                    registerDocument(source.getDocumentRoot(), new DocumentURI(source.getSystemId()));
                }
            }
            // System.err.println("*** TransformDocument");
            if (executable==null) {
                throw new XPathException("Stylesheet has not been compiled");
            }

            openMessageEmitter();

            XPathContextMajor initialContext = newXPathContext();

            if (source != null) {

                initialContextItem = source;
                contextForGlobalVariables = source.getRoot();

                SequenceIterator currentIter = SingletonIterator.makeIterator(source);
                if (initialTemplate != null) {
                    currentIter.next();
                }
                initialContext.setCurrentIterator(currentIter);
            }

            initializeController();

            PipelineConfiguration pipe = makePipelineConfiguration();
            Receiver result = openResult(pipe, initialContext, target, ResultDocument.APPEND_CONTENT);

            // Process the source document by applying template rules to the initial context node

            if (initialTemplate == null) {
                initialContextItem = source;
                Mode mode = getRuleManager().getMode(initialMode, false);
                if (mode == null || (initialMode != null && mode.isEmpty())) {
                    throw new XPathException("Requested initial mode " +
                            (initialMode == null ? "" : initialMode.getDisplayName()) +
                            " does not exist", "XTDE0045");
                }
                TailCall tc = ApplyTemplates.applyTemplates(
View Full Code Here

    public TailCall processLeavingTail(XPathContext context) throws XPathException {
        return apply(context, useTailRecursion);
    }

    protected TailCall apply(XPathContext context, boolean returnTailCall) throws XPathException {
        Mode thisMode = mode;
        if (useCurrentMode) {
            thisMode = context.getCurrentMode();
        }

        // handle parameters if any
View Full Code Here

TOP

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

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.