public void createAndAddIndexGroups( final IndexEntry[] theIndexEntries, final IndexConfiguration theConfiguration, final Document theDocument, final Locale theLocale) { final IndexComparator indexEntryComparator = new IndexComparator(theLocale); final IndexGroup[] indexGroups = indexGroupProcessor.process(theIndexEntries, theConfiguration, theLocale); final Element rootElement = theDocument.getDocumentElement(); final Element indexGroupsElement = theDocument.createElementNS(namespace_url, "index.groups"); indexGroupsElement.setPrefix(prefix); for (final IndexGroup group : indexGroups) { // Create group element final Node groupElement = theDocument.createElementNS(namespace_url, "index.group"); groupElement.setPrefix(prefix); // Create group label element and index entry childs final Element groupLabelElement = theDocument.createElementNS(namespace_url, "label"); groupLabelElement.setPrefix(prefix); groupLabelElement.appendChild(theDocument.createTextNode(group.getLabel())); groupElement.appendChild(groupLabelElement); final Node[] entryNodes = transformToNodes(group.getEntries(), theDocument, indexEntryComparator); for (final Node entryNode : entryNodes) { groupElement.appendChild(entryNode); } indexGroupsElement.appendChild(groupElement); } rootElement.appendChild(indexGroupsElement); }
/** * Creates element with "prefix" in "namespace_url" with given name for the target document * * @param theTargetDocument target document * @param theName name * @return new element */ private Element createElement(final Document theTargetDocument, final String theName) { final Element indexEntryNode = theTargetDocument.createElementNS(this.namespace_url, theName); indexEntryNode.setPrefix(this.prefix); return indexEntryNode; }