Package org.apache.cocoon.template.script.event

Examples of org.apache.cocoon.template.script.event.StartDocument


        return resolveTemplate(uri, null);
    }

    public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
        Source input = null;
        StartDocument doc = null;
        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            input = resolver.resolveURI(uri);
            SourceValidity validity = null;

            String storeUri = JX_STORE_PREFIX + input.getURI();
            doc = (StartDocument) getStore().get(storeUri);

            // TODO: why was this previously in synchronized( getCache() )?
            if (doc != null) {
                boolean recompile = false;
                if (doc.getSourceValidity() == null) {
                    recompile = true;
                } else {
                    int valid = doc.getSourceValidity().isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        validity = input.getValidity();
                        valid = doc.getSourceValidity().isValid(validity);
                    }
                    if (valid != SourceValidity.VALID) {
                        recompile = true;
                    }
                }
                if (recompile) {
                    doc = null; // recompile
                }
            }

            if (doc == null) {
                Parser parser = new Parser(new ParsingContext(this.stringTemplateParser, this.instructionFactory));
                // call getValidity before using the stream is faster if
                // the source is a SitemapSource
                if (validity == null) {
                    validity = input.getValidity();
                }
                SourceUtil.parse(manager, input, parser);
                doc = parser.getStartEvent();
                doc.setUri(input.getURI());
                doc.setSourceValidity(validity);

                getStore().store(storeUri, doc);
            }
        } catch (SourceException se) {
            throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);
View Full Code Here


                }
                buf.append(val != null ? val.toString() : "");
            }
            uri = buf.toString();
        }
        StartDocument doc;
        try {
            doc = executionContext.getScriptManager().resolveTemplate(uri);
        } catch (ProcessingException exc) {
            throw new SAXParseException(exc.getMessage(), getLocation(), exc);
        }

        if (this.select != null) {
            objectModel.markLocalContext();
            try {
                Object obj = this.select.getValue(objectModel);
                objectModel.put(ObjectModel.CONTEXTBEAN, obj);
                objectModel.fillContext();
            } catch (Exception exc) {
                throw new SAXParseException(exc.getMessage(), getLocation(), exc);
            } catch (Error err) {
                throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
            }
        }
        try {
            Invoker.execute(consumer, objectModel, executionContext, macroContext, namespaces, doc.getNext(), doc
                    .getEndDocument());
        } catch (Exception exc) {
            throw new SAXParseException("Exception occurred in imported template " + uri + ": " + exc.getMessage(),
                    getLocation(), exc);
        }
View Full Code Here

        return resolveTemplate(uri, null);
    }

    public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
        Source input = null;
        StartDocument doc = null;
        try {
            input = sourceResolver.resolveURI(uri);
            SourceValidity validity = null;

            String storeUri = JX_STORE_PREFIX + input.getURI();
            doc = (StartDocument) getStore().get(storeUri);

            // TODO: why was this previously in synchronized( getCache() )?
            if (doc != null) {
                boolean recompile = false;
                if (doc.getSourceValidity() == null) {
                    recompile = true;
                } else {
                    int valid = doc.getSourceValidity().isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        validity = input.getValidity();
                        valid = doc.getSourceValidity().isValid(validity);
                    }
                    if (valid != SourceValidity.VALID) {
                        recompile = true;
                    }
                }
                if (recompile) {
                    doc = null; // recompile
                }
            }

            if (doc == null) {
                Parser parser = new Parser(new ParsingContext(this.stringTemplateParser, this.instructionFactory));
                // call getValidity before using the stream is faster if
                // the source is a SitemapSource
                if (validity == null) {
                    validity = input.getValidity();
                }
                SourceUtil.parse(saxParser, input, parser);
                doc = parser.getStartEvent();
                doc.setUri(input.getURI());
                doc.setSourceValidity(validity);

                getStore().store(storeUri, doc);
            }
        } catch (SourceException se) {
            throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);
View Full Code Here

        return resolveTemplate(uri, null);
    }

    public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
        Source input = null;
        StartDocument doc = null;
        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            input = resolver.resolveURI(uri);
            SourceValidity validity = null;

            String storeUri = JX_STORE_PREFIX + input.getURI();
            doc = (StartDocument) getStore().get(storeUri);

            // TODO: why was this previously in synchronized( getCache() )?
            if (doc != null) {
                boolean recompile = false;
                if (doc.getSourceValidity() == null) {
                    recompile = true;
                } else {
                    int valid = doc.getSourceValidity().isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        validity = input.getValidity();
                        valid = doc.getSourceValidity().isValid(validity);
                    }
                    if (valid != SourceValidity.VALID) {
                        recompile = true;
                    }
                }
                if (recompile) {
                    doc = null; // recompile
                }
            }

            if (doc == null) {
                Parser parser = new Parser(new ParsingContext(this.stringTemplateParser, this.instructionFactory));
                // call getValidity before using the stream is faster if
                // the source is a SitemapSource
                if (validity == null) {
                    validity = input.getValidity();
                }
                SourceUtil.parse(manager, input, parser);
                doc = parser.getStartEvent();
                doc.setUri(input.getURI());
                doc.setSourceValidity(validity);

                getStore().store(storeUri, doc);
            }
        } catch (SourceException se) {
            throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);
View Full Code Here

                    buf.append(val != null ? val.toString() : "");
                }
            }
            uri = buf.toString();
        }
        StartDocument doc;
        try {
            doc = executionContext.getScriptManager().resolveTemplate(uri);
        } catch (ProcessingException exc) {
            throw new SAXParseException(exc.getMessage(), getLocation(), exc);
        }
        ExpressionContext selectExpressionContext = expressionContext;
        if (this.select != null) {
            try {
                Object obj = this.select.getValue(expressionContext);
                selectExpressionContext = new ExpressionContext(expressionContext);
                selectExpressionContext.setContextBean(obj);
                TemplateObjectModelHelper.fillContext(obj, selectExpressionContext);
            } catch (Exception exc) {
                throw new SAXParseException(exc.getMessage(), getLocation(), exc);
            } catch (Error err) {
                throw new SAXParseException(err.getMessage(), getLocation(),
                                            new ErrorHolder(err));
            }
        }
        try {
            Invoker.execute(consumer, expressionContext, executionContext,
                            macroContext, doc.getNext(), doc.getEndDocument());
        } catch (Exception exc) {
            throw new SAXParseException(
                                        "Exception occurred in imported template " + uri
                                        + ": " + exc.getMessage(), getLocation(), exc);
        }
View Full Code Here

                }
                buf.append(val != null ? val.toString() : "");
            }
            uri = buf.toString();
        }
        StartDocument doc;
        try {
            doc = executionContext.getScriptManager().resolveTemplate(uri);
        } catch (ProcessingException exc) {
            throw new SAXParseException(exc.getMessage(), getLocation(), exc);
        }

        if (this.select != null) {
            objectModel.markLocalContext();
            try {
                Object obj = this.select.getValue(objectModel);
                objectModel.put(ObjectModel.CONTEXTBEAN, obj);
                objectModel.fillContext();
            } catch (Exception exc) {
                throw new SAXParseException(exc.getMessage(), getLocation(), exc);
            } catch (Error err) {
                throw new SAXParseException(err.getMessage(), getLocation(), new ErrorHolder(err));
            }
        }
        try {
            Invoker.execute(consumer, objectModel, executionContext, macroContext, namespaces, doc.getNext(), doc
                    .getEndDocument());
        } catch (Exception exc) {
            throw new SAXParseException("Exception occurred in imported template " + uri + ": " + exc.getMessage(),
                    getLocation(), exc);
        }
View Full Code Here

                    buf.append(val != null ? val.toString() : "");
                }
            }
            uri = buf.toString();
        }
        StartDocument doc;
        try {
            doc = executionContext.getScriptManager().resolveTemplate(uri);
        } catch (ProcessingException exc) {
            throw new SAXParseException(exc.getMessage(), getLocation(), exc);
        }
        ExpressionContext selectExpressionContext = expressionContext;
        if (this.select != null) {
            try {
                Object obj = this.select.getValue(expressionContext);
                selectExpressionContext = new ExpressionContext(expressionContext);
                selectExpressionContext.setContextBean(obj);
                TemplateObjectModelHelper.fillContext(obj, selectExpressionContext);
            } catch (Exception exc) {
                throw new SAXParseException(exc.getMessage(), getLocation(), exc);
            } catch (Error err) {
                throw new SAXParseException(err.getMessage(), getLocation(),
                                            new ErrorHolder(err));
            }
        }
        try {
            Invoker.execute(consumer, expressionContext, executionContext,
                            macroContext, doc.getNext(), doc.getEndDocument());
        } catch (Exception exc) {
            throw new SAXParseException(
                                        "Exception occurred in imported template " + uri
                                        + ": " + exc.getMessage(), getLocation(), exc);
        }
View Full Code Here

        return resolveTemplate(uri, null);
    }

    public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
        Source input = null;
        StartDocument doc = null;
        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            input = resolver.resolveURI(uri);
            SourceValidity validity = null;

            String storeUri = JX_STORE_PREFIX + input.getURI();
            doc = (StartDocument) getStore().get(storeUri);

            // TODO: why was this previously in synchronized( getCache() )?
            if (doc != null) {
                boolean recompile = false;
                if (doc.getSourceValidity() == null) {
                    recompile = true;
                } else {
                    int valid = doc.getSourceValidity().isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        validity = input.getValidity();
                        valid = doc.getSourceValidity().isValid(validity);
                    }
                    if (valid != SourceValidity.VALID) {
                        recompile = true;
                    }
                }
                if (recompile) {
                    doc = null; // recompile
                }
            }

            if (doc == null) {
                Parser parser = new Parser(new ParsingContext(this.stringTemplateParser, this.instructionFactory));
                // call getValidity before using the stream is faster if
                // the source is a SitemapSource
                if (validity == null) {
                    validity = input.getValidity();
                }
                SourceUtil.parse(manager, input, parser);
                doc = parser.getStartEvent();
                doc.setUri(input.getURI());
                doc.setSourceValidity(validity);

                getStore().store(storeUri, doc);
            }
        } catch (SourceException se) {
            throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);
View Full Code Here

TOP

Related Classes of org.apache.cocoon.template.script.event.StartDocument

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.