Package com.jclark.xsl.conv

Examples of com.jclark.xsl.conv.NumberListFormat


    NumberListFormat instantiate(ProcessContext context,
                                 Node sourceNode)
        throws XSLException
    {
        if (formatExpr != null) {
            NumberListFormat tem = (NumberListFormat)format.clone();
            tem.setFormat(formatExpr.eval(sourceNode, context));
            return tem;
        }
        return format;
    }
View Full Code Here


     */
    public void invoke(ProcessContext context, Node node,
                       Result result)
        throws XSLException
    {
        NumberListFormat format = formatTemplate.instantiate(context, node);
        int n;
        if (count == null) {
            if (node.getType() == Node.ELEMENT) {
                n = numberUp(node.getName(), format, context, node, result);
            } else {
                n = 0;
            }
        } else {
            Cache cache = (Cache)context.get(this);
            if (cache == null) {
                cache = new Cache();
                context.put(this, cache);
            }
            n = numberUp(format, context, cache, node, result);
        }
        if (n == 0) {
            result.characters(format.getPrefix(0));
        }
        result.characters(format.getSuffix());
    }
View Full Code Here

    }

    public void invoke(ProcessContext context, Node node, Result result)
        throws XSLException
    {
        NumberListFormat format = formatTemplate.instantiate(context, node);
        result.characters(format.getPrefix(0));
        result.characters(format.formatNumber(0,
                                              Math.round((float)expr.eval(node, context))));
        result.characters(format.getSuffix());
    }
View Full Code Here


    public void invoke(ProcessContext context, Node node,
                       Result result) throws XSLException
    {
        NumberListFormat format = formatTemplate.instantiate(context, node);
        result.characters(format.getPrefix(0));
        if (count == null) {
            if (node.getType() == Node.ELEMENT) {
                Name name = node.getName();
                int n = 0;
                for (NodeIterator iter = node.getParent().getChildren();;) {
                    Node tem = iter.next();
                    if (name.equals(tem.getName()) &&
                        tem.getType() == Node.ELEMENT) {
                        n++;
                        if (tem.equals(node))
                            break;
                    }
                }
                result.characters(format.formatNumber(0, n));
            }
        } else {
            if (node.getType() == Node.ATTRIBUTE)
                node = node.getParent();
            do {
                Node parent = node.getParent();
                if (count.matches(node, context)) {
                    int n = 0;
                    for (NodeIterator iter = parent.getChildren() ; ; ) {
                        Node tem = iter.next();
                        if (count.matches(tem, context)) {
                            ++n;
                            if (tem.equals(node))
                                break;
                        }
                    }
                    result.characters(format.formatNumber(0, n));
                    break;
                }
                if (from != null && from.matches(node, context))
                    break;
                node = parent;
            } while (node != null);
        }
        result.characters(format.getSuffix());
    }
View Full Code Here

    }

    public void invoke(ProcessContext context, Node node,
                       Result result) throws XSLException
    {
        NumberListFormat format = formatTemplate.instantiate(context, node);
        Node root = node.getRoot();
        Hashtable documentTable = (Hashtable)context.get(this);
        if (documentTable == null) {
            documentTable = new Hashtable();
            context.put(this, documentTable);
        }
        Cache cache;
        if (count != null) {
            cache = (Cache)documentTable.get(root);
            if (cache == null) {
                cache = new Cache();
                documentTable.put(root, cache);
                int n = 0;
                for (NodeIterator iter =
                         new DescendantsOrSelfNodeIterator(root);;) {
                    Node tem = iter.next();
                    if (tem == null) {
                        break;
                    }
                    if (from != null && from.matches(tem, context)) {
                        n = 0;
                    } else if (count.matches(tem, context)) {
                        cache.append(tem, n++);
                    }
                }
            }
        }
        else if (node.getType() == Node.ELEMENT) {
            Hashtable elementTable = (Hashtable)documentTable.get(root);
            if (elementTable == null) {
                elementTable = new Hashtable();
                documentTable.put(root, elementTable);
            }
            Name name = node.getName();
            cache = (Cache)elementTable.get(name);
            if (cache == null) {
                cache = new Cache();
                elementTable.put(name, cache);
                int n = 0;
                for (NodeIterator iter = new DescendantsOrSelfNodeIterator(root);;) {
                    Node tem = iter.next();
                    if (tem == null)
                        break;
                    if (from != null && from.matches(tem, context))
                        n = 0;
                    else if (name.equals(tem.getName()) && tem.getType() == Node.ELEMENT)
                        cache.append(tem, n++);
                }
            }
        }
        else
            return;
        result.characters(format.getPrefix(0));
        result.characters(format.formatNumber(0, cache.getNumber(node)));
        result.characters(format.getSuffix());
    }
View Full Code Here

TOP

Related Classes of com.jclark.xsl.conv.NumberListFormat

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.