private Iterator<Attribute> specified(Iterator<Attribute> src) { if (src == null) { return null; } final ArrayList<Attribute> al = new ArrayList<Attribute>(); while (src.hasNext()) { Attribute att = src.next(); if (att.isSpecified()) { al.add(att); } } return al.isEmpty() ? null : al.iterator(); }
/** * This will handle printing of a {@link Attribute}. * * @param fstack * the FormatStack * @param basedoc * The org.w3c.dom.Document for creating DOM Nodes * @param attribute * <code>Attribute</code> to write. * @return The input JDOM Attribute converted to a DOM Attr */ protected org.w3c.dom.Attr printAttribute(final FormatStack fstack, final org.w3c.dom.Document basedoc, final Attribute attribute) { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return null; } org.w3c.dom.Attr attr = basedoc.createAttributeNS( attribute.getNamespaceURI(), attribute.getQualifiedName()); attr.setValue(attribute.getValue()); return attr; }
/** * This will handle printing of an <code>{@link Attribute}</code>. * * @param out * <code>XMLStreamWriter</code> to use. * @param fstack * The current FormatStack * @param attribute * <code>Attribute</code> to output * @throws XMLStreamException * if the output fails */ protected void printAttribute(final XMLStreamWriter out, final FormatStack fstack, final Attribute attribute) throws XMLStreamException { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return; } final Namespace ns = attribute.getNamespace(); if (ns == Namespace.NO_NAMESPACE) { out.writeAttribute(attribute.getName(), attribute.getValue()); } else { out.writeAttribute(ns.getPrefix(), ns.getURI(), attribute.getName(), attribute.getValue()); } }
/** * This will handle printing of an <code>{@link Attribute}</code>. * * @param out * <code>Writer</code> to use. * @param fstack * The current FormatStack * @param attribute * <code>Attribute</code> to output * @throws IOException * if the output fails */ protected void printAttribute(final Writer out, final FormatStack fstack, final Attribute attribute) throws IOException { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return; } write(out, " "); write(out, attribute.getQualifiedName()); write(out, "="); write(out, "\""); attributeEscapedEntitiesFilter(out, fstack, attribute.getValue()); write(out, "\""); }
if (!a.isSpecified() && fstack.isSpecifiedAttributesOnly()) { continue;
private void printAttribute(Writer out, FormatStack fstack, Attribute attribute, boolean printMultiLine) throws IOException { if (!attribute.isSpecified() && fstack.isSpecifiedAttributesOnly()) { return; } if (printMultiLine) { write(out, StringUtils.defaultString(fstack.getLineSeparator())); write(out, StringUtils.defaultString(fstack.getLevelIndent())); write(out, StringUtils.defaultString(fstack.getIndent())); } else { write(out, " "); } write(out, attribute.getQualifiedName()); write(out, "="); write(out, "\""); attributeEscapedEntitiesFilter(out, fstack, attribute.getValue()); write(out, "\""); }