Package net.sf.saxon.trans

Examples of net.sf.saxon.trans.Mode


    }

    public Expression compile(Executable exec) throws TransformerConfigurationException
    {
        Boolean preserve = new Boolean(getFingerprint()==StandardNames.XSL_PRESERVE_SPACE);
        Mode stripperRules = getPrincipalStylesheet().getStripperRules();

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

        StringTokenizer st = new StringTokenizer(elements);
        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;
            try {
                if (s.equals("*")) {
                    nt = AnyNodeTest.getInstance();
                    pat.setNodeTest(nt);
                    stripperRules.addRule(
                                pat,
                                preserve,
                                getPrecedence(),
                                -0.5);

                } 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(
                                  getTargetNamePool(),
                              Type.ELEMENT,
                              uri);
                    pat.setNodeTest(nt);
                    stripperRules.addRule(
                          pat,
                          preserve,
                          getPrecedence(),
                          -0.25);
                } else if (s.startsWith("*:")) {
                    if (s.length()==2) {
                        compileError("No local name after '*:'");
                    }
                    String localname = s.substring(2);
                    nt = new LocalNameTest(
                                  getTargetNamePool(),
                              Type.ELEMENT,
                              localname);
                    pat.setNodeTest(nt);
                    stripperRules.addRule(
                          pat,
                          preserve,
                          getPrecedence(),
                          -0.25);
                } else {
                    String prefix;
                    String localName = null;
                    String uri = null;
                    try {
                        String[] parts = Name.getQNameParts(s);
                        prefix = parts[0];
                        uri = getURIForPrefix(prefix, false);
                        localName = parts[1];
                    } catch (QNameException err) {
                        compileError("Element name " + s + " is not a valid QName");
                    }
                    NamePool target = getTargetNamePool();
                    int nameCode = target.allocate("", uri, localName);
                    nt = new NameTest(Type.ELEMENT, nameCode, getNamePool());
                    pat.setNodeTest(nt);
                  stripperRules.addRule(
                        pat,
                        preserve,
                        getPrecedence(),
                        0);
                }
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

        allocateSlots(exp);
        if (match != null) {
            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());
                }
View Full Code Here

    }

    public Expression compile(Executable exec) throws XPathException
    {
        Boolean preserve = Boolean.valueOf(getFingerprint() == StandardNames.XSL_PRESERVE_SPACE);
        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 = null;
                String uri = null;
                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

            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

TOP

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