Search in sources :

Example 1 with DTDAttribute

use of org.eclipse.wst.dtd.core.internal.emf.DTDAttribute in project webtools.sourceediting by eclipse.

the class DTDPrinter method visitAttributes.

private void visitAttributes(DTDElement elem) {
    Collection attrs = elem.getDTDAttribute();
    Iterator i = attrs.iterator();
    if (attrs != null && i.hasNext()) {
        DTDAttribute attrib = (DTDAttribute) i.next();
        String comment = attrib.getComment();
        if (comment != null && comment.length() > 0)
            // $NON-NLS-1$ //$NON-NLS-2$
            sb.append("<!--\n ").append(comment).append("\n-->\n");
        // $NON-NLS-1$ //$NON-NLS-2$
        sb.append("<!ATTLIST " + elem.getName() + "\n");
        // $NON-NLS-1$
        sb.append(" ");
        updateStartOffset(attrib, sb.length());
        sb.append(attrib.unparse());
        updateEndOffset(attrib, sb.length());
        // $NON-NLS-1$
        sb.append("\n");
        for (; i.hasNext(); ) {
            attrib = (DTDAttribute) i.next();
            comment = attrib.getComment();
            if (comment != null && comment.length() > 0) {
                // $NON-NLS-1$
                sb.append(">\n");
                if (comment != null && comment.length() > 0)
                    // $NON-NLS-1$ //$NON-NLS-2$
                    sb.append("<!--\n ").append(comment).append("\n-->\n");
                // $NON-NLS-1$ //$NON-NLS-2$
                sb.append("<!ATTLIST " + elem.getName() + "\n");
            }
            // $NON-NLS-1$
            sb.append(" ");
            updateStartOffset(attrib, sb.length());
            sb.append(attrib.unparse());
            updateEndOffset(attrib, sb.length());
            // $NON-NLS-1$
            sb.append("\n");
        }
        // $NON-NLS-1$
        sb.append(">\n");
    }
}
Also used : Iterator(java.util.Iterator) Collection(java.util.Collection) DTDAttribute(org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)

Example 2 with DTDAttribute

use of org.eclipse.wst.dtd.core.internal.emf.DTDAttribute in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method hasIDAttribute.

public boolean hasIDAttribute(DTDAttribute dtdattr) {
    boolean hasID = false;
    DTDElement element = dtdattr.getDTDElement();
    EList attrs = element.getDTDAttribute();
    Iterator i = attrs.iterator();
    while (i.hasNext()) {
        DTDAttribute attr = (DTDAttribute) i.next();
        DTDType dType = attr.getDTDType();
        if (dType instanceof DTDBasicType) {
            if (((DTDBasicType) dType).getKind().getValue() == DTDBasicTypeKind.ID) {
                hasID = true;
                break;
            }
        }
    }
    return hasID;
}
Also used : EList(org.eclipse.emf.common.util.EList) DTDBasicType(org.eclipse.wst.dtd.core.internal.emf.DTDBasicType) Iterator(java.util.Iterator) DTDElement(org.eclipse.wst.dtd.core.internal.emf.DTDElement) DTDType(org.eclipse.wst.dtd.core.internal.emf.DTDType) DTDAttribute(org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)

Example 3 with DTDAttribute

use of org.eclipse.wst.dtd.core.internal.emf.DTDAttribute in project webtools.sourceediting by eclipse.

the class DTDModelBuilder method addAttribute.

/**
 * Create a DTDAttribute from the xml4j attribute
 */
public void addAttribute(DTDElement dtdelement, AttNode ad) {
    DTDAttribute dtdattr = getFactory().createDTDAttribute();
    dtdelement.getDTDAttribute().add(dtdattr);
    finishAttribute(dtdattr, ad);
}
Also used : DTDAttribute(org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)

Example 4 with DTDAttribute

use of org.eclipse.wst.dtd.core.internal.emf.DTDAttribute in project webtools.sourceediting by eclipse.

the class DTDElementImpl method getAttributeDetail.

public String getAttributeDetail() {
    // $NON-NLS-1$
    String attributeString = "";
    Collection attributes = getDTDAttribute();
    if (attributes != null) {
        boolean seenOne = false;
        for (java.util.Iterator i = attributes.iterator(); i.hasNext(); ) {
            if (seenOne) {
                // $NON-NLS-1$
                attributeString = attributeString + ", ";
            } else {
                seenOne = true;
            }
            // end of else
            attributeString = attributeString + ((DTDAttribute) i.next()).getName();
        }
    }
    // end of if ()
    return attributeString;
}
Also used : Collection(java.util.Collection) DTDAttribute(org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)

Aggregations

DTDAttribute (org.eclipse.wst.dtd.core.internal.emf.DTDAttribute)4 Collection (java.util.Collection)2 Iterator (java.util.Iterator)2 EList (org.eclipse.emf.common.util.EList)1 DTDBasicType (org.eclipse.wst.dtd.core.internal.emf.DTDBasicType)1 DTDElement (org.eclipse.wst.dtd.core.internal.emf.DTDElement)1 DTDType (org.eclipse.wst.dtd.core.internal.emf.DTDType)1