Example usage for org.dom4j Attribute getNamespace

List of usage examples for org.dom4j Attribute getNamespace

Introduction

In this page you can find the example usage for org.dom4j Attribute getNamespace.

Prototype

Namespace getNamespace();

Source Link

Document

Returns the Namespace of this element if one exists otherwise null is returned returned.

Usage

From source file:architecture.common.xml.XmlWriter.java

License:Apache License

/**
 * Writes the attributes of the given element
 *
 *///from  w  w w.j  a va 2 s . c  o  m
protected void writeAttributes(Element element) throws IOException {

    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
        Namespace ns = attribute.getNamespace();
        if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
            String prefix = ns.getPrefix();
            String uri = namespaceStack.getURI(prefix);
            if (!ns.getURI().equals(uri)) { // output a new namespace
                // declaration
                writeNamespace(ns);
                namespaceStack.push(ns);
            }
        }

        // If the attribute is a namespace declaration, check if we have
        // already
        // written that declaration elsewhere (if that's the case, it must
        // be
        // in the namespace stack
        String attName = attribute.getName();
        if (attName.startsWith("xmlns:")) {
            String prefix = attName.substring(6);
            if (namespaceStack.getNamespaceForPrefix(prefix) == null) {
                String uri = attribute.getValue();
                namespaceStack.push(prefix, uri);
                writeNamespace(prefix, uri);
            }
        } else if (attName.equals("xmlns")) {
            if (namespaceStack.getDefaultNamespace() == null) {
                String uri = attribute.getValue();
                namespaceStack.push(null, uri);
                writeNamespace(null, uri);
            }
        } else {
            char quote = format.getAttributeQuoteCharacter();
            writer.write(" ");
            writer.write(attribute.getQualifiedName());
            writer.write("=");
            writer.write(quote);
            writeEscapeAttributeEntities(attribute.getValue());
            writer.write(quote);
        }
    }
}

From source file:architecture.ee.util.xml.XmlWriter.java

License:Apache License

/** Writes the attributes of the given element
  *//  ww w . java 2  s.com
  */
protected void writeAttributes(Element element) throws IOException {

    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
        Namespace ns = attribute.getNamespace();
        if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
            String prefix = ns.getPrefix();
            String uri = namespaceStack.getURI(prefix);
            if (!ns.getURI().equals(uri)) { // output a new namespace declaration
                writeNamespace(ns);
                namespaceStack.push(ns);
            }
        }

        // If the attribute is a namespace declaration, check if we have already
        // written that declaration elsewhere (if that's the case, it must be
        // in the namespace stack
        String attName = attribute.getName();
        if (attName.startsWith("xmlns:")) {
            String prefix = attName.substring(6);
            if (namespaceStack.getNamespaceForPrefix(prefix) == null) {
                String uri = attribute.getValue();
                namespaceStack.push(prefix, uri);
                writeNamespace(prefix, uri);
            }
        } else if (attName.equals("xmlns")) {
            if (namespaceStack.getDefaultNamespace() == null) {
                String uri = attribute.getValue();
                namespaceStack.push(null, uri);
                writeNamespace(null, uri);
            }
        } else {
            char quote = format.getAttributeQuoteCharacter();
            writer.write(" ");
            writer.write(attribute.getQualifiedName());
            writer.write("=");
            writer.write(quote);
            writeEscapeAttributeEntities(attribute.getValue());
            writer.write(quote);
        }
    }
}

From source file:com.christophermrossi.jpt.PageTemplateImpl.java

License:Open Source License

AttributesImpl getAttributes(Element element, Expressions expressions) throws PageTemplateException {
    AttributesImpl attributes = new AttributesImpl();
    for (Iterator i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = (Attribute) i.next();
        Namespace namespace = attribute.getNamespace();
        //String prefix = namespace.getPrefix();
        //System.err.println( "attribute: name=" + attribute.getName() + "\t" +
        //                    "qualified name=" + attribute.getQualifiedName() + "\t" +
        //                    "ns prefix=" + namespace.getPrefix() + "\t" +
        //                    "ns uri=" + namespace.getURI() );
        //String qualifiedName = attribute.getName();
        //String name = qualifiedName;
        //if ( qualifiedName.startsWith( prefix + ":" ) ) {
        //    name = qualifiedName.substring( prefix.length() + 1 );
        //}//from  w w  w . jav a 2s  . c om
        String name = attribute.getName();

        // Handle JPT attributes
        //if ( prefix.equals( talNamespacePrefix ) ) {
        if (TAL_NAMESPACE_URI.equals(namespace.getURI())) {
            // tal:define
            if (name.equals("define")) {
                expressions.define = attribute.getValue();
            }

            // tal:condition
            else if (name.equals("condition")) {
                expressions.condition = attribute.getValue();
            }

            // tal:repeat
            else if (name.equals("repeat")) {
                expressions.repeat = attribute.getValue();
            }

            // tal:content
            else if (name.equals("content")) {
                expressions.content = attribute.getValue();
            }

            // tal:replace
            else if (name.equals("replace")) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = "";
                }
                expressions.content = attribute.getValue();
            }

            // tal:attributes
            else if (name.equals("attributes")) {
                expressions.attributes = attribute.getValue();
            }

            // tal:omit-tag
            else if (name.equals("omit-tag")) {
                expressions.omitTag = attribute.getValue();
            }

            // tal:evaluate
            else if (name.equals("evaluate")) {
                expressions.evaluate = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException("unknown tal attribute: " + name);
            }
        }
        //else if ( prefix.equals( metalNamespacePrefix ) ) 
        else if (METAL_NAMESPACE_URI.equals(namespace.getURI())) {
            // metal:use-macro
            if (name.equals("use-macro")) {
                expressions.useMacro = attribute.getValue();
            }

            // metal:define-slot
            else if (name.equals("define-slot")) {
                expressions.defineSlot = attribute.getValue();
            }

            // metal:define-macro
            // metal:fill-slot
            else if (name.equals("define-macro") || name.equals("fill-slot")) {
                // these are ignored here, as they don't affect processing of current
                // template, but are called from other templates
            }

            // error
            else {
                throw new PageTemplateException("unknown metal attribute: " + name);
            }
        }

        // Pass on all other attributes
        else {
            //String qualifiedName = namespace.getPrefix() + ":" + name;
            attributes.addAttribute(namespace.getURI(), name, attribute.getQualifiedName(), "CDATA",
                    attribute.getValue());
            //attributes.addAttribute( getNamespaceURIFromPrefix(prefix), name, qualifiedName, "CDATA", attribute.getValue() );
        }
    }
    return attributes;
}

From source file:com.cladonia.xml.ExchangerXMLWriter.java

License:Open Source License

protected void writeAttributes(Element element) throws IOException {

    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    for (int i = 0, size = element.attributeCount(); i < size; i++) {
        Attribute attribute = element.attribute(i);
        Namespace ns = attribute.getNamespace();
        if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
            String prefix = ns.getPrefix();
            String uri = namespaceStack.getURI(prefix);
            if (!ns.getURI().equals(uri)) { // output a new namespace declaration
                writeNamespace(ns);/*from  w ww.  jav  a 2  s .c  o  m*/
                namespaceStack.push(ns);
            }
        }

        writeAttribute(attribute);
    }
}

From source file:com.shopximity.jpt.PageTemplateImpl.java

License:Open Source License

AttributesImpl getAttributes(Element element, Expressions expressions) throws PageTemplateException {
    AttributesImpl attributes = new AttributesImpl();
    for (Iterator i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = (Attribute) i.next();
        Namespace namespace = attribute.getNamespace();
        //String prefix = namespace.getPrefix();
        //System.err.println( "attribute: name=" + attribute.getName() + "\t" +
        //                    "qualified name=" + attribute.getQualifiedName() + "\t" +
        //                    "ns prefix=" + namespace.getPrefix() + "\t" +
        //                    "ns uri=" + namespace.getURI() );
        //String qualifiedName = attribute.getName();
        //String name = qualifiedName;
        //if ( qualifiedName.startsWith( prefix + ":" ) ) {
        //    name = qualifiedName.substring( prefix.length() + 1 );
        //}/* www.  java2  s  .  c  om*/
        String name = attribute.getName();

        // Handle JPT attributes
        //if ( prefix.equals( talNamespacePrefix ) ) {
        if (TAL_NAMESPACE_URI.equals(namespace.getURI())) {
            // tal:define
            if (name.equals("define")) {
                expressions.define = attribute.getValue();
            }

            // tal:condition
            else if (name.equals("condition")) {
                expressions.condition = attribute.getValue();
            }

            // tal:repeat
            else if (name.equals("repeat")) {
                expressions.repeat = attribute.getValue();
            }

            // tal:content
            else if (name.equals("content")) {
                expressions.content = attribute.getValue();
            }

            // tal:replace
            else if (name.equals("replace")) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = "";
                }
                expressions.content = attribute.getValue();
            }

            // tal:attributes
            else if (name.equals("attributes")) {
                expressions.attributes = attribute.getValue();
            }

            // tal:omit-tag
            else if (name.equals("omit-tag")) {
                expressions.omitTag = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException("unknown tal attribute: " + name);
            }
        }
        //else if ( prefix.equals( metalNamespacePrefix ) ) 
        else if (METAL_NAMESPACE_URI.equals(namespace.getURI())) {
            // metal:use-macro
            if (name.equals("use-macro")) {
                expressions.useMacro = attribute.getValue();
            }

            // metal:define-slot
            else if (name.equals("define-slot")) {
                expressions.defineSlot = attribute.getValue();
            }

            // metal:define-macro
            // metal:fill-slot
            else if (name.equals("define-macro") || name.equals("fill-slot")) {
                // these are ignored here, as they don't affect processing of current
                // template, but are called from other templates
            }

            // error
            else {
                throw new PageTemplateException("unknown metal attribute: " + name);
            }
        }

        // Pass on all other attributes
        else {
            //String qualifiedName = namespace.getPrefix() + ":" + name;
            attributes.addAttribute(namespace.getURI(), name, attribute.getQualifiedName(), "CDATA",
                    attribute.getValue());
            //attributes.addAttribute( getNamespaceURIFromPrefix(prefix), name, qualifiedName, "CDATA", attribute.getValue() );
        }
    }
    return attributes;
}

From source file:com.webslingerz.jpt.PageTemplateImpl.java

License:Open Source License

AttributesImpl getAttributes(Element element, Expressions expressions) throws PageTemplateException {
    AttributesImpl attributes = new AttributesImpl();
    for (Iterator i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = (Attribute) i.next();
        Namespace namespace = attribute.getNamespace();
        Namespace elementNamespace = element.getNamespace();
        if (!namespace.hasContent() && elementNamespace.hasContent())
            namespace = elementNamespace;
        // String prefix = namespace.getPrefix();
        // System.err.println( "attribute: name=" + attribute.getName() +
        // "\t" +
        // "qualified name=" + attribute.getQualifiedName() + "\t" +
        // "ns prefix=" + namespace.getPrefix() + "\t" +
        // "ns uri=" + namespace.getURI() );
        // String qualifiedName = attribute.getName();
        // String name = qualifiedName;
        // if ( qualifiedName.startsWith( prefix + ":" ) ) {
        // name = qualifiedName.substring( prefix.length() + 1 );
        // }/*from  w w  w. j a  v a 2  s  . c  o m*/
        String name = attribute.getName();

        // Handle JPT attributes
        // if ( prefix.equals( talNamespacePrefix ) ) {
        if (TAL_NAMESPACE_URI.equals(namespace.getURI())
                || (!strict && TAL_NAMESPACE_PREFIX.equals(namespace.getPrefix()))) {

            // tal:define
            if (name.equals("define")) {
                expressions.define = attribute.getValue();
            }

            // tal:condition
            else if (name.equals("condition")) {
                expressions.condition = attribute.getValue();
            }

            // tal:repeat
            else if (name.equals("repeat")) {
                expressions.repeat = attribute.getValue();
            }

            // tal:content
            else if (name.equals("content")) {
                expressions.content = attribute.getValue();
            }

            // tal:replace
            else if (name.equals("replace")) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = "";
                }
                expressions.content = attribute.getValue();
            }

            // tal:attributes
            else if (name.equals("attributes")) {
                expressions.attributes = attribute.getValue();
            }

            // tal:omit-tag
            else if (name.equals("omit-tag")) {
                expressions.omitTag = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException("unknown tal attribute: " + name);
            }
        }
        // else if ( prefix.equals( metalNamespacePrefix ) )
        else if (METAL_NAMESPACE_URI.equals(namespace.getURI())
                || (!strict && METAL_NAMESPACE_PREFIX.equals(namespace.getPrefix()))) {

            // metal:use-macro
            if (name.equals("use-macro")) {
                expressions.useMacro = attribute.getValue();
            }

            // metal:define-slot
            else if (name.equals("define-slot")) {
                expressions.defineSlot = attribute.getValue();
            }

            // metal:define-macro
            else if (name.equals("define-macro")) {
                //System.out.println("Defining macro: " + attribute.getValue());
                Element el = element.createCopy();
                el.remove(attribute);
                macros.put(attribute.getValue(), new MacroImpl(el));
                expressions.macro = true;
            }

            // metal:fill-slot
            else if (name.equals("fill-slot")) {
                // these are ignored here, as they don't affect processing
                // of current template, but are called from other templates
            }

            // error
            else {
                throw new PageTemplateException("unknown metal attribute: " + name);
            }
        }

        // Pass on all other attributes
        else {
            String nsURI = namespace.getURI();
            // String qualifiedName = namespace.getPrefix() + ":" + name;
            attributes.addAttribute(nsURI, name, attribute.getQualifiedName(), "CDATA", attribute.getValue());
            if (nsURI != "" && namespace != elementNamespace) {
                String prefix = namespace.getPrefix();
                String qName = "xmlns:" + prefix;
                if (attributes.getIndex(qName) == -1) {
                    // add xmlns for this attribute
                    attributes.addAttribute("", prefix, qName, "CDATA", nsURI);
                }
            }
            // attributes.addAttribute( getNamespaceURIFromPrefix(prefix),
            // name, qualifiedName, "CDATA", attribute.getValue() );
        }
    }
    return attributes;
}

From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JXMLOutputter.java

License:Open Source License

/**
* <p>//w w  w  . ja  va  2 s .c  om
* This will handle printing out an <code>{@link Attribute}</code> list.
* </p>
*
* @param attributes <code>List</code> of Attribute objcts
* @param out <code>Writer</code> to write to
*/
protected void printAttributes(List attributes, Element parent, Writer out, TDOM4JNamespaceStack namespaces)
        throws IOException {

    // I do not yet handle the case where the same prefix maps to
    // two different URIs. For attributes on the same element
    // this is illegal; but as yet we don't throw an exception
    // if someone tries to do this
    Set prefixes = new HashSet();

    for (int i = 0, size = attributes.size(); i < size; i++) {
        Attribute attribute = (Attribute) attributes.get(i);
        Namespace ns = attribute.getNamespace();
        if (ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
            String prefix = ns.getPrefix();
            String uri = namespaces.getURI(prefix);
            if (!ns.getURI().equals(uri)) { // output a new namespace decl
                printNamespace(ns, out);
                namespaces.push(ns);
            }
        }

        out.write(" ");
        out.write(attribute.getQualifiedName());
        out.write("=");

        out.write("\"");
        out.write(escapeAttributeEntities(attribute.getValue()));
        out.write("\"");
    }

}

From source file:org.zenonpagetemplates.onePhaseImpl.PageTemplateImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
AttributesImpl getAttributes(Element element, Expressions expressions) throws PageTemplateException {

    AttributesImpl attributes = new AttributesImpl();
    for (Iterator<Attribute> i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = i.next();
        Namespace namespace = attribute.getNamespace();
        String name = attribute.getName();

        // Handle ZPT attributes
        if (TAL_NAMESPACE_URI.equals(namespace.getURI())) {

            // tal:define
            if (name.equals(TAL_DEFINE)) {
                expressions.define = attribute.getValue();
            }//from ww  w  .ja  v a  2 s.  c om

            // tal:condition
            else if (name.equals(TAL_CONDITION)) {
                expressions.condition = attribute.getValue();
            }

            // tal:repeat
            else if (name.equals(TAL_REPEAT)) {
                expressions.repeat = attribute.getValue();
            }

            // tal:content
            else if (name.equals(TAL_CONTENT)) {
                expressions.content = attribute.getValue();
            }

            // tal:replace
            else if (name.equals(TAL_REPLACE)) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = VOID_STRING;
                }
                expressions.content = attribute.getValue();
            }

            // tal:attributes
            else if (name.equals(TAL_ATTRIBUTES)) {
                expressions.attributes = attribute.getValue();
            }

            // tal:omit-tag
            else if (name.equals(TAL_OMIT_TAG)) {
                expressions.omitTag = attribute.getValue();
            }

            // tal:on-error
            else if (name.equals(TAL_ON_ERROR)) {
                expressions.onError = attribute.getValue();
            }

            // tal:tag
            else if (name.equals(TAL_TAG)) {
                expressions.tag = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException(
                        "Unknown tal attribute: " + name + " in '" + this.template.getName() + "' template");
            }
        } else if (METAL_NAMESPACE_URI.equals(namespace.getURI())) {

            // metal:use-macro
            if (name.equals(METAL_USE_MACRO)) {
                expressions.useMacro = attribute.getValue();
            }

            // metal:define-slot
            else if (name.equals(METAL_DEFINE_SLOT)) {
                expressions.defineSlot = attribute.getValue();
            }

            // metal:define-macro
            // metal:fill-slot
            else if (name.equals(METAL_DEFINE_MACRO) || name.equals(METAL_FILL_SLOT)) {
                // these are ignored here, as they don't affect processing of current
                // template, but are called from other templates
            }

            // error
            else {
                throw new PageTemplateException(
                        "Unknown metal attribute: " + name + " in '" + this.template.getName() + "' template");
            }
        }

        else if (I18N_NAMESPACE_URI.equals(namespace.getURI())) {

            // i18n:domain
            if (name.equals(I18N_DOMAIN)) {
                expressions.i18nDomain = attribute.getValue();
            }

            // i18n:define
            else if (name.equals(I18N_DEFINE)) {
                expressions.i18nDefine = attribute.getValue();
            }

            // i18n:content
            else if (name.equals(I18N_CONTENT)) {
                expressions.i18nContent = attribute.getValue();
            }

            // i18n:replace
            else if (name.equals(I18N_REPLACE)) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = VOID_STRING;
                }
                expressions.i18nContent = attribute.getValue();
            }

            // i18n:attributes
            else if (name.equals(I18N_ATTRIBUTES)) {
                expressions.i18nAttributes = attribute.getValue();
            }

            // i18n:params
            else if (name.equals(I18N_PARAMS)) {
                expressions.i18nParams = attribute.getValue();
            }

            // i18n:on-error
            else if (name.equals(I18N_ON_ERROR)) {
                expressions.i18nOnError = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException(
                        "Unknown i18n attribute: " + name + " in '" + this.template.getName() + "' template");
            }

        }

        // Pass on all other attributes
        else {
            attributes.addAttribute(namespace.getURI(), name, attribute.getQualifiedName(), CDATA,
                    attribute.getValue());
        }
    }
    return attributes;
}

From source file:org.zenonpagetemplates.twoPhasesImpl.ZPTDocumentFactory.java

License:Open Source License

@SuppressWarnings("unchecked")
static private void mapAttributes(Element element, ZPTElement zptElement, ZPTDocument zptDocument)
        throws PageTemplateException {

    String talOmitTag = null;//w  w w . jav  a2  s . c  om
    boolean isReplace = false;

    for (Iterator<Attribute> i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = i.next();
        Namespace namespace = attribute.getNamespace();
        String name = attribute.getName();
        String namespacePrefix = namespace.getPrefix();

        // Handle ZPT attributes
        if (TwoPhasesPageTemplate.TAL_NAMESPACE_URI.equals(namespace.getURI())) {

            // tal:define
            if (name.equals(TwoPhasesPageTemplate.TAL_DEFINE)) {
                zptElement.addDynamicAttribute(new TALDefine(namespacePrefix, attribute.getValue()));
            }

            // tal:condition
            else if (name.equals(TwoPhasesPageTemplate.TAL_CONDITION)) {
                zptElement.addDynamicAttribute(new TALCondition(namespacePrefix, attribute.getValue()));
            }

            // tal:repeat
            else if (name.equals(TwoPhasesPageTemplate.TAL_REPEAT)) {
                zptElement.addDynamicAttribute(new TALRepeat(namespacePrefix, attribute.getValue()));
            }

            // tal:content
            else if (name.equals(TwoPhasesPageTemplate.TAL_CONTENT)) {
                zptElement.addDynamicAttribute(new TALContent(namespacePrefix, attribute.getValue()));
            }

            // tal:replace
            else if (name.equals(TwoPhasesPageTemplate.TAL_REPLACE)) {
                isReplace = true;
                zptElement.addDynamicAttribute(new TALContent(namespacePrefix, attribute.getValue()));
            }

            // tal:attributes
            else if (name.equals(TwoPhasesPageTemplate.TAL_ATTRIBUTES)) {
                zptElement.addDynamicAttribute(new TALAttributes(namespacePrefix, attribute.getValue()));
            }

            // tal:omit-tag
            else if (name.equals(TwoPhasesPageTemplate.TAL_OMIT_TAG)) {
                talOmitTag = attribute.getValue();
            }

            // tal:on-error
            else if (name.equals(TwoPhasesPageTemplate.TAL_ON_ERROR)) {
                zptElement.addDynamicAttribute(new TALOnError(namespacePrefix, attribute.getValue()));
            }

            // tal:tag
            else if (name.equals(TwoPhasesPageTemplate.TAL_TAG)) {
                zptElement.addDynamicAttribute(new TALTag(namespacePrefix, attribute.getValue()));
            }

            // error
            else {
                throw new PageTemplateException("Unknown TAL attribute: " + name + " in template");
            }
        }

        else if (TwoPhasesPageTemplate.METAL_NAMESPACE_URI.equals(namespace.getURI())) {

            // metal:use-macro
            if (name.equals(TwoPhasesPageTemplate.METAL_USE_MACRO)) {
                zptElement.addDynamicAttribute(new METALUseMacro(namespacePrefix, attribute.getValue()));
            }

            // metal:define-slot
            else if (name.equals(TwoPhasesPageTemplate.METAL_DEFINE_SLOT)) {
                zptElement.addDynamicAttribute(new METALDefineSlot(namespacePrefix, attribute.getValue()));
            }

            // metal:define-macro
            else if (name.equals(TwoPhasesPageTemplate.METAL_DEFINE_MACRO)) {
                zptElement.addDynamicAttribute(new METALDefineMacro(namespacePrefix, attribute.getValue()));
            }

            // metal:fill-slot
            else if (name.equals(TwoPhasesPageTemplate.METAL_FILL_SLOT)) {
                zptElement.addDynamicAttribute(new METALFillSlot(namespacePrefix, attribute.getValue()));
            }

            // error
            else {
                throw new PageTemplateException("Unknown metal attribute: " + name + " in template");
            }
        }

        else if (TwoPhasesPageTemplate.I18N_NAMESPACE_URI.equals(namespace.getURI())) {

            // i18n:domain
            if (name.equals(TwoPhasesPageTemplate.I18N_DOMAIN)) {
                zptElement.addDynamicAttribute(new I18NDomain(namespacePrefix, attribute.getValue()));
            }

            // i18n:define
            else if (name.equals(TwoPhasesPageTemplate.I18N_DEFINE)) {
                zptElement.addDynamicAttribute(new I18NDefine(namespacePrefix, attribute.getValue()));
            }

            // i18n:content
            else if (name.equals(TwoPhasesPageTemplate.I18N_CONTENT)) {
                zptElement.addDynamicAttribute(new I18NContent(namespacePrefix, attribute.getValue()));
            }

            // i18n:replace
            else if (name.equals(TwoPhasesPageTemplate.I18N_REPLACE)) {
                isReplace = true;
                zptElement.addDynamicAttribute(new I18NContent(namespacePrefix, attribute.getValue()));
            }

            // i18n:attributes
            else if (name.equals(TwoPhasesPageTemplate.I18N_ATTRIBUTES)) {
                zptElement.addDynamicAttribute(new I18NAttributes(namespacePrefix, attribute.getValue()));
            }

            // i18n:params
            else if (name.equals(TwoPhasesPageTemplate.I18N_PARAMS)) {
                zptElement.addDynamicAttribute(new I18NParams(namespacePrefix, attribute.getValue()));
            }

            // i18n:on-error
            else if (name.equals(TwoPhasesPageTemplate.I18N_ON_ERROR)) {
                zptElement.addDynamicAttribute(new I18NOnError(namespacePrefix, attribute.getValue()));
            }

            // error
            else {
                throw new PageTemplateException("Unknown i18n attribute: " + name + " in template");
            }
        }

        // Pass on all other attributes
        else {
            zptElement.addStaticAttribute(new StaticAttributeImpl(namespacePrefix, name, attribute.getValue()));
        }
    }

    //  Add omit-tag
    if (talOmitTag != null) {
        zptElement.addDynamicAttribute(new TALOmitTag(zptDocument.getTALPrefix(), talOmitTag));

    } else if (isReplace) {
        zptElement.addDynamicAttribute(new TALOmitTag(zptDocument.getTALPrefix(), VOID_STRING));
    }
}