Example usage for org.dom4j Attribute getQualifiedName

List of usage examples for org.dom4j Attribute getQualifiedName

Introduction

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

Prototype

String getQualifiedName();

Source Link

Document

Returns the fully qualified name of this element.

Usage

From source file:org.orbeon.oxf.xml.XMLUtils.java

License:Open Source License

/**
 * Convert dom4j attributes to SAX attributes.
 *
 * @param element   dom4j Element/*from ww w .  j  ava2  s  .c om*/
 * @return          SAX Attributes
 */
public static AttributesImpl getSAXAttributes(Element element) {
    final AttributesImpl result = new AttributesImpl();
    for (Iterator i = element.attributeIterator(); i.hasNext();) {
        final org.dom4j.Attribute attribute = (org.dom4j.Attribute) i.next();

        result.addAttribute(attribute.getNamespaceURI(), attribute.getName(), attribute.getQualifiedName(),
                XMLReceiverHelper.CDATA, attribute.getValue());
    }
    return result;
}

From source file:org.withinsea.izayoi.cortile.template.html.parser.HTMLWriter.java

License:Mozilla Public License

@Override
@SuppressWarnings("unchecked")
protected void writeAttributes(Element element) throws IOException {
    for (Attribute attribute : (List<Attribute>) element.attributes()) {
        String name = attribute.getName();
        if (!name.equals("xmlns") && !name.startsWith("xmlns:")) {
            if (attribute instanceof SurroundableAttr) {
                SurroundableAttr sattr = (SurroundableAttr) attribute;
                writeString(" " + sattr.getPrefix() + attribute.getQualifiedName() + "=\"");
                writeEscapeAttributeEntities(attribute.getValue());
                writer.write("\"");
                writeString(sattr.getSuffix());
            } else {
                writeString(" " + attribute.getQualifiedName() + "=\"");
                writeEscapeAttributeEntities(attribute.getValue());
                writer.write("\"");
            }/*from  ww w .j a  v a 2  s .c  o m*/
        }
    }
}

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   w  w  w .ja  va2 s .  c  o  m

            // 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;
}