src/main/java/eu/digitisation/layout/ALTOPage.java
TextComponent parse(Element element) {
        String id = element.getAttribute("ID");
        ComponentType type = ComponentType.valueOf(FileType.ALTO, element.getTagName());
        String subtype = element.getAttribute("TYPE");
        String content = element.getAttribute("CONTENT");
        BoundingBox bbox = getBBox(element);
        Polygon frontier = (bbox == null) ? null : bbox.asPolygon();
        List<TextComponent> array = new ArrayList<TextComponent>();
        NodeList children = element.getChildNodes();
        int number = components.size();

        components.add(null);  // reserve the place for this component

        for (int nchild = 0; nchild < children.getLength(); ++nchild) {
            Node child = children.item(nchild);
            if (child instanceof Element) {
                Element e = (Element) child;
                String tag = e.getTagName();
                if (tag.equals("PrintSpace")
                        || tag.equals("ComposedBlock")
                        || tag.equals("TextBlock")
                        || tag.equals("TextLine")
                        || tag.equals("String")) {
                    TextComponent subcomponent = parse(e);
                    array.add(subcomponent);
                }
            }
        }
        TextComponent component = new TextComponent(id, type, subtype, content, frontier);
        components.set(number, component);
        subcomponents.put(component, array);
        return component;
    }
/**
     * Parse an XML element and retrieve the associated text component
     *
     * @param element an XML element
     * @return the text component associated with this element
     */
Parse an XML element and retrieve the associated text component
@param element an XML element
@return the text component associated with this element
Parse an XML element and retrieve the associated text component @param element an XML element @return the text component associated with this element
TextComponent parse(Element element) {
        String id = element.getAttribute("ID");
        ComponentType type = ComponentType.valueOf(FileType.ALTO, element.getTagName());
        String subtype = element.getAttribute("TYPE");
        String content = element.getAttribute("CONTENT");
        BoundingBox bbox = getBBox(element);
        Polygon frontier = (bbox == null) ? null : bbox.asPolygon();
        List<TextComponent> array = new ArrayList<TextComponent>();
        NodeList children = element.getChildNodes();
        int number = components.size();
        components.add(null);  
        for (int nchild = 0; nchild < children.getLength(); ++nchild) {
            Node child = children.item(nchild);
            if (child instanceof Element) {
                Element e = (Element) child;
                String tag = e.getTagName();
                if (tag.equals("PrintSpace")
                        || tag.equals("ComposedBlock")
                        || tag.equals("TextBlock")
                        || tag.equals("TextLine")
                        || tag.equals("String")) {
                    TextComponent subcomponent = parse(e);
                    array.add(subcomponent);
                }
            }
        }
        TextComponent component = new TextComponent(id, type, subtype, content, frontier);
        components.set(number, component);
        subcomponents.put(component, array);
        return component;
    }
TextComponent parse ( Element element ) { String id = element . getAttribute ( "ID" ) ; ComponentType type = ComponentType . valueOf ( FileType . ALTO , element . getTagName ( ) ) ; String subtype = element . getAttribute ( "TYPE" ) ; String content = element . getAttribute ( "CONTENT" ) ; BoundingBox bbox = getBBox ( element ) ; Polygon frontier = ( bbox == null ) ? null : bbox . asPolygon ( ) ; List < TextComponent > array = new ArrayList < TextComponent > ( ) ; NodeList children = element . getChildNodes ( ) ; int number = components . size ( ) ; components . add ( null ) ; for ( int nchild = 0 ; nchild < children . getLength ( ) ; ++ nchild ) { Node child = children . item ( nchild ) ; if ( child instanceof Element ) { Element e = ( Element ) child ; String tag = e . getTagName ( ) ; if ( tag . equals ( "PrintSpace" ) || tag . equals ( "ComposedBlock" ) || tag . equals ( "TextBlock" ) || tag . equals ( "TextLine" ) || tag . equals ( "String" ) ) { TextComponent subcomponent = parse ( e ) ; array . add ( subcomponent ) ; } } } TextComponent component = new TextComponent ( id , type , subtype , content , frontier ) ; components . set ( number , component ) ; subcomponents . put ( component , array ) ; return component ; }
Parse an XML element and retrieve the associated text component
 @param element an XML element
 @return the text component associated with this element
Parse an XML element and retrieve the associated text component @param element an XML element @return the text component associated with this element
// reserve the place for this component