private void processColGroup()

in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/TableSimplifier.java [116:182]


    private void processColGroup(Element colGroup)
            throws SAXException, DocgenException {
        boolean usesAtts = false;
        
        int span = 1;  // Default from the HTML spec.
        Alignment align = null;
        VAlignment valign = null;
        
        NamedNodeMap atts = colGroup.getAttributes();
        int attCnt = atts.getLength();
        fetchAtts: for (int attIdx = 0; attIdx < attCnt; attIdx++) {
            Attr att = (Attr) atts.item(attIdx);
            String attNS = att.getNamespaceURI();
            if (attNS != null && attNS.length() != 0) {
                continue fetchAtts;
            }
            String attName = att.getLocalName();
            String attValue = att.getValue().trim();
            
            if (attName.equals(A_SPAN)) {
                usesAtts = true;
                span = parseSpanAttribute(attValue, A_SPAN, E_COLGROUP);
            } else if (attName.equals(A_ALIGN)) {
                align = parseAlignAttribute(attValue, E_COLGROUP);
            } else if (attName.equals(A_VALIGN)) {
                valign = parseVAlignAttribute(attValue, E_COLGROUP);
            } else {
                throw new DocgenException("The \"" + attName
                        + "\" attribute of the \"" + E_COLGROUP
                        + "\" element is not supported by Docgen.");
            }
        }  // fetchAtts
        
        if (usesAtts) {
            for (int i = 0; i < span; i++) {
                colGroupAligns.add(align);
                colGroupVAligns.add(valign);
            }
        }
        
        NodeList children = colGroup.getChildNodes();
        int childCnt = children.getLength();
        fetchChildren: for (int childIdx = 0; childIdx < childCnt; childIdx++) {
            Node child = children.item(childIdx);
            if (child instanceof Element) {
                Element elem = (Element) child;
                if (!elem.getNamespaceURI().equals(XMLNS_DOCBOOK5)) {
                    continue fetchChildren;
                }
                String elemName = elem.getLocalName();
                
                if (elemName.equals(E_COL)) {
                    if (usesAtts) {
                        throw new SAXException("The \"" + E_COLGROUP
                                + "\" already used attributes, so it can't "
                                + "have \"" + E_COL + "\" elements in it.");
                    }
                    processCol(elem, align, valign);
                } else {
                    throw new SAXException("The \"" + elemName + "\" element "
                            + "is unexpected inside \"" + E_COLGROUP + "\".");
                }
            }
            // Ignore non-elements
        }
        
    }