Package org.apache.cocoon.xml

Examples of org.apache.cocoon.xml.SaxBuffer$EndDocument


    private void i18nCharacters(String textValue) throws SAXException {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("i18n message text = '" + textValue + "'");
        }

        SaxBuffer buffer;
        switch (current_state) {
            case STATE_INSIDE_TEXT:
                buffer = text_recorder;
                break;

            case STATE_INSIDE_PARAM:
                buffer = param_recorder;
                break;

            case STATE_INSIDE_WHEN:
            case STATE_INSIDE_OTHERWISE:
                // Previously handeld to avoid the String() conversion.
                return;

            case STATE_INSIDE_TRANSLATE:
                if (tr_text_recorder == null) {
                    tr_text_recorder = new ParamSaxBuffer();
                }
                buffer = tr_text_recorder;
                break;

            case STATE_INSIDE_CHOOSE:
                // No characters allowed. Send an exception ?
                if (getLogger().isDebugEnabled()) {
                    textValue = textValue.trim();
                    if (textValue.length() > 0) {
                        getLogger().debug("No characters allowed inside <i18n:choose> tag. Received: " + textValue);
                    }
                }
                return;

            case STATE_INSIDE_DATE:
            case STATE_INSIDE_DATE_TIME:
            case STATE_INSIDE_TIME:
            case STATE_INSIDE_NUMBER:
                // Trim text values to avoid parsing errors.
                textValue = textValue.trim();
                if (textValue.length() > 0) {
                    if (formattingParams.get(I18N_VALUE_ATTRIBUTE) == null) {
                        formattingParams.put(I18N_VALUE_ATTRIBUTE, textValue);
                    } else {
                        // ignore the text inside of date element
                    }
                }
                return;

            default:
                throw new IllegalStateException(getClass().getName() +
                                                " developer's fault: characters not handled. " +
                                                "Current state: " + current_state);
        }

        char[] ch = textValue.toCharArray();
        buffer.characters(ch, 0, ch.length);
    }
View Full Code Here


        if (colonPos != -1) {
            catalogueID = key.substring(0, colonPos);
            key = key.substring(colonPos + 1, key.length());
        }

        final SaxBuffer text = getMessage(catalogueID, key);
        if (text == null) {
            getLogger().warn("Translation not found for attribute " +
                             name + " in element <" + element + ">");
            return untranslated;
        }
        return text.toString();
    }
View Full Code Here

     * A default value is returned if message is not found.
     *
     * @return SaxBuffer containing message, or defaultValue if not found.
     */
    private ParamSaxBuffer getMessage(String key, ParamSaxBuffer defaultValue) {
        SaxBuffer value = getMessage(currentCatalogueId, key);
        if (value == null) {
            return defaultValue;
        }

        return new ParamSaxBuffer(value);
View Full Code Here

     */
    public static XMLizable compileElementContent(Element element) {
        // Remove location information
        LocationAttributes.remove(element, true);

        SaxBuffer saxBuffer = new SaxBuffer();
        DOMStreamer domStreamer = new DOMStreamer();
        domStreamer.setContentHandler(saxBuffer);

        NodeList childNodes = element.getChildNodes();
        for (int i = 0; i < childNodes.getLength(); i++) {
View Full Code Here

            return hBuffer;
        }

        public void endElement(String uri, String loc, String raw)
        throws SAXException {
            SaxBuffer buffer = endBuffer();
            final Repeater repeater = (Repeater) contextWidget;
            final int rowCount = repeater.getSize();
            pushHandler(hNested);
            contextWidgets.addFirst(contextWidget);
            for (int i = 0; i < rowCount; i++) {
                contextWidget = repeater.getRow(i);
                if (isVisible(contextWidget)) {
                    buffer.toSAX(EffectWidgetReplacingPipe.this);
                }
            }
            contextWidget = (Widget) contextWidgets.removeFirst();
            popHandler();
            widget = null;
View Full Code Here

            return hBuffer;
        }

        public void endElement(String uri, String loc, String raw)
        throws SAXException {
            SaxBuffer buffer = endBuffer();
            final Repeater repeater = (Repeater) widget;
            final int rowCount = repeater.getSize();
            pushHandler(hNested);
            contextWidgets.addFirst(contextWidget);
            for (int i = 0; i < rowCount; i++) {
                contextWidget = repeater.getRow(i);
                if (isVisible(contextWidget)) {
                    buffer.toSAX(EffectWidgetReplacingPipe.this);
                }
            }
            contextWidget = (Widget) contextWidgets.removeFirst();
            popHandler();
            widget = null;
View Full Code Here

     */
    protected class NewHandler extends CopyHandler {
        public Handler startElement(String uri, String loc, String raw, Attributes attrs)
        throws SAXException {
            String id = getRequiredAttributeValue(loc, attrs, "id");
            SaxBuffer buffer = (SaxBuffer) classes.get(id);
            if (buffer == null) {
                throw new SAXException("New: Class '" + id + "' does not exist, " +
                                       "at " + getLocation());
            }
            pushHandler(hNested);
            buffer.toSAX(EffectWidgetReplacingPipe.this);
            popHandler();
            return this;
        }
View Full Code Here

        }
        if (locator != null) {
            locators.addFirst(locator);
            locator = new LocatorImpl(locator);
        }
        this.buffer = new SaxBuffer();
    }
View Full Code Here

        }
        this.buffer = new SaxBuffer();
    }

    protected SaxBuffer endBuffer() {
        SaxBuffer buffer = this.buffer;
        if (this.buffers != null && this.buffers.size() > 0) {
            this.buffer = (SaxBuffer) this.buffers.removeFirst();
        } else {
            this.buffer = null;
        }
View Full Code Here

            if (localName.equals(WIDGET) || localName.equals(REPEATER_WIDGET)) {
                checkContextWidgetAvailable(qName);
                inWidgetElement = true;
                widgetElementNesting = elementNestingCounter;
                gotStylingElement = false;
                saxBuffer = new SaxBuffer();
                // retrieve widget here, but its XML will only be streamed in the endElement call
                widget = getWidget(attributes);
                repeaterWidget = localName.equals(REPEATER_WIDGET);
                if (repeaterWidget && !(widget instanceof Repeater)) {
                    throw new SAXException("WoodyTemplateTransformer: the element \"repeater-widget\" can only be used for repeater widgets.");
View Full Code Here

TOP

Related Classes of org.apache.cocoon.xml.SaxBuffer$EndDocument

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.