@Override
 protected List<Item> transform(List<Item> items) {
   Tag enclosure = null;
   List<String> children = null;
   List<Tag> enclosureChildTags = null;
   for (Item i : items) {
     if (i instanceof Tag) {
       Tag tag = (Tag) i;
       if (isEnclosure(tag)) {
         if (tag.getType() == Tag.Type.OPEN) {
           // found opening enclosure
           enclosure = tag;
           children = getChildren(enclosure);
           enclosureChildTags = new ArrayList<Tag>();
         } else if (tag.getType() == Tag.Type.CLOSE) {
           // tidy up on close tag
           updateEnclosureChildId(enclosure, children, enclosureChildTags);
           enclosure = null;
           children = null;
           enclosureChildTags = null;
         }
       } else if (enclosure != null && !children.isEmpty()) {
         // if we have open enclosure tag and children to find
         int index = checkIfTagIsChild(tag, children, enclosureChildTags);
         if (index != -1) {
           onChildFound(tag, children, enclosureChildTags, index);
         }
       }
     }
   }
   return items;
 }
 /**
  * Checks for an id attribute if a brix:tile then a wicket:id
  *
  * @param tag
  * @return
  */
 private String getTagId(Tag tag) {
   Map<String, String> attributes = tag.getAttributeMap();
   String id = null;
   if (attributes != null) {
     // look for brix:tile first "id" first then "wicket:id"
     if (tag instanceof TileTag) {
       id = attributes.get(AbstractContainer.MARKUP_TILE_ID);
     }
     if (id == null) {
       id = attributes.get(getWicketIdAttributeName(tag));
     }
     return id;
   }
   return null;
 }
 /**
  * Gets the value of the "child" attribute and splits the path into a list
  *
  * @param enclosure
  * @return ids
  */
 private List<String> getChildren(Tag enclosure) {
   Map<String, String> attributes = enclosure.getAttributeMap();
   if (attributes != null) {
     if (attributes.containsKey(EnclosureHandler.CHILD_ATTRIBUTE)) {
       // split for nested components
       String[] children =
           attributes.get(EnclosureHandler.CHILD_ATTRIBUTE).split("" + Component.PATH_SEPARATOR);
       ArrayList<String> list = new ArrayList<String>();
       for (String child : children) {
         list.add(child);
       }
       return list;
     }
   }
   return null;
 }
 /**
  * Replaces the supplied enclosure child tag with the actual resolved comma separated component
  * path
  *
  * @param enclosure
  * @param children
  * @param enclosureChildTags
  */
 private void updateEnclosureChildId(
     Tag enclosure, List<String> children, List<Tag> enclosureChildTags) {
   Map<String, String> attributes = enclosure.getAttributeMap();
   if (attributes != null) {
     String child = "";
     for (int i = 0; i < children.size(); i++) {
       String childid = children.get(i);
       if (childid != null) {
         child += (child.length() > 0 ? Component.PATH_SEPARATOR : "") + childid;
       } else {
         Tag tag = enclosureChildTags.get(i);
         String id = getGeneratedTagId(tag);
         if (id != null) {
           // nested children are delimited by commas
           child += (child.length() > 0 ? Component.PATH_SEPARATOR : "") + id;
         }
       }
     }
     attributes.put(EnclosureHandler.CHILD_ATTRIBUTE, child);
   }
 }
 private boolean isEnclosure(Tag tag) {
   return ENCLOSURE.equals(tag.getName());
 }