Package net.sf.saxon.trans

Examples of net.sf.saxon.trans.Mode$Rule


            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().getDefaultMode();
        }
        if (context.getCurrentIterator()==null) {
            XPathException e = new XPathException("There is no context item");
View Full Code Here


            throw e;
        }
        Template currentTemplate = (Template)currentTemplateRule.getAction();
        int min = currentTemplate.getMinImportPrecedence();
        int max = currentTemplate.getPrecedence()-1;
        Mode mode = context.getCurrentMode();
        if (mode == null) {
            mode = controller.getRuleManager().getDefaultMode();
        }
        if (context.getCurrentIterator()==null) {
            XPathException e = new XPathException("Cannot call xsl:apply-imports when there is no context item");
View Full Code Here

        if (match != null) {
            int slots = match.allocateSlots(getStaticContext(), getSlotManager(), 0);
            RuleManager mgr = getPrincipalStylesheet().getRuleManager();
            for (int i=0; i<modeNames.length; i++) {
                StructuredQName nc = modeNames[i];
                Mode mode = mgr.getMode(nc, true);
                if (prioritySpecified) {
                    mgr.setHandler(match, compiledTemplate, mode, getPrecedence(), priority);
                } else {
                    mgr.setHandler(match, compiledTemplate, mode, getPrecedence());
                }
                mode.allocatePatternSlots(slots);
                if (mode.isStreamable()) {
                    compiledTemplate.setStreamable(true);
                }
            }

            allocatePatternSlots(slots);
View Full Code Here

    public Expression compile(Executable exec) throws XPathException
    {
        RuleTarget preserve =
                (getFingerprint() == StandardNames.XSL_PRESERVE_SPACE ? Stripper.PRESERVE : Stripper.STRIP);
        Mode stripperRules = getPrincipalStylesheet().getStripperRules();

        // elements is a space-separated list of element names

        StringTokenizer st = new StringTokenizer(elements, " \t\n\r", false);
        while (st.hasMoreTokens()) {
            String s = st.nextToken();
            NodeTestPattern pat = new NodeTestPattern();
            // following information is used in conflict warnings
            pat.setOriginalText(s);
            pat.setSystemId(getSystemId());
            pat.setLineNumber(getLineNumber());
            NodeTest nt;
            if (s.equals("*")) {
                nt = AnyNodeTest.getInstance();
                pat.setNodeTest(nt);
                stripperRules.addRule(
                            pat,
                            preserve,
                            getPrecedence(),
                            -0.5, true);

            } else if (s.endsWith(":*")) {
                if (s.length()==2) {
                    compileError("No prefix before ':*'");
                }
                String prefix = s.substring(0, s.length()-2);
                String uri = getURIForPrefix(prefix, false);
                nt = new NamespaceTest(
                                    getNamePool(),
                                    Type.ELEMENT,
                                    uri);
                pat.setNodeTest(nt);
                stripperRules.addRule(
                            pat,
                            preserve,
                            getPrecedence(),
                            -0.25, true);
            } else if (s.startsWith("*:")) {
                if (s.length()==2) {
                    compileError("No local name after '*:'");
                }
                String localname = s.substring(2);
                nt = new LocalNameTest(
                                    getNamePool(),
                                    Type.ELEMENT,
                                    localname);
                pat.setNodeTest(nt);
                stripperRules.addRule(
                            pat,
                            preserve,
                            getPrecedence(),
                            -0.25, true);
            } else {
                String prefix;
                String localName;
                String uri;
                try {
                    String[] parts = getConfiguration().getNameChecker().getQNameParts(s);
                    prefix = parts[0];
                    if (parts[0].equals("")) {
                        uri = getDefaultXPathNamespace();
                    } else {
                        uri = getURIForPrefix(prefix, false);
                        if (uri == null) {
                            undeclaredNamespaceError(prefix, "XTSE0280");
                            return null;
                        }
                    }
                    localName = parts[1];
                } catch (QNameException err) {
                    compileError("Element name " + s + " is not a valid QName", "XTSE0280");
                    return null;
                }
                NamePool target = getNamePool();
                int nameCode = target.allocate("", uri, localName);
                nt = new NameTest(Type.ELEMENT, nameCode, getNamePool());
                pat.setNodeTest(nt);
                stripperRules.addRule(
                            pat,
                            preserve,
                            getPrecedence(),
                            0, true);
            }
View Full Code Here

        super.allocateSlots(exp);
        if (match!=null) {
            RuleManager mgr = getPrincipalStylesheet().getRuleManager();
            for (int i=0; i<modeNameCodes.length; i++) {
                int nc = modeNameCodes[i];
                Mode mode = mgr.getMode(nc);
                if (nc != Mode.DEFAULT_MODE && nc != Mode.ALL_MODES) {
                    mode.setModeNameCode(nc);
                                // used for tracing only
                }
                if (prioritySpecified) {
                    mgr.setHandler(match, compiledTemplate, mode, getPrecedence(), priority);
                } else {
View Full Code Here

            DynamicError e = new DynamicError("There is no current template rule");
            e.setXPathContext(context);
            e.setErrorCode("XT0560");
            throw e;
        }
        Mode mode = context.getCurrentMode();
        if (context.getCurrentIterator()==null) {
            DynamicError e = new DynamicError("There is no context item");
            e.setXPathContext(context);
            e.setErrorCode("XT0565");
            throw e;
View Full Code Here

            throw e;
        }

        int min = currentTemplate.getMinImportPrecedence();
        int max = currentTemplate.getPrecedence()-1;
        Mode mode = context.getCurrentMode();
        if (context.getCurrentIterator()==null) {
            DynamicError e = new DynamicError("Cannot call xsl:apply-imports when there is no context item");
            e.setXPathContext(context);
            e.setErrorCode("XT0565");
            throw e;
View Full Code Here

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

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

        // handle parameters if any
View Full Code Here

     * Get the rules determining which nodes are to be stripped from the tree
     */

    protected Mode getStripperRules() {
        if (exec.getStripperRules() == null) {
            exec.setStripperRules(new Mode());
        }
        return exec.getStripperRules();
    }
View Full Code Here

                return s;
            }
        }
        Stripper stripper;
        if (executable==null) {
            stripper = new Stripper(new Mode());
        } else {
            stripper = executable.newStripper();
        }
    stripper.setController(this);
        if (b != null) {
View Full Code Here

TOP

Related Classes of net.sf.saxon.trans.Mode$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.