Example usage for org.dom4j Node getName

List of usage examples for org.dom4j Node getName

Introduction

In this page you can find the example usage for org.dom4j Node getName.

Prototype

String getName();

Source Link

Document

getName returns the name of this node.

Usage

From source file:com.noterik.bart.fs.ingest.SimpleIngestHandler.java

License:Open Source License

/**
 * only used in OU//from   w ww.j  av  a  2s .  c om
 * creates the raw images for the nelson jobs (thumbnails)
 * @param uri
 */

// not used anymore !!
public void createImageRawsForOU(String uri) {

    String domain = URIParser.getDomainFromUri(uri);

    String configUri = "/domain/" + domain + "/config/image";
    Document doc = FSXMLRequestHandler.instance().getNodeProperties(configUri, false);

    List<Element> raws = (List<Element>) doc.selectNodes("//rawimage");
    logger.debug("OU image config\n" + doc.asXML());
    // go through all elements
    for (Element raw : raws) {
        String id = raw.valueOf("@id");
        String rawUri = uri.substring(0, uri.lastIndexOf("/") + 1) + id + "/properties";
        Element props = (Element) raw.selectSingleNode("./properties");
        StringBuffer fsxml = null;
        // create the raw
        if (props != null) {
            fsxml = new StringBuffer("<fsxml><properties>");
            Node child = null;
            for (Iterator i = ((Element) props).nodeIterator(); i.hasNext();) {
                child = (Node) i.next();
                fsxml.append("<" + child.getName() + ">" + child.getText() + "</" + child.getName() + ">");
            }
            fsxml.append("</properties></fsxml>");
            logger.debug("ou uri: " + rawUri + " xml\n" + fsxml.toString());
            FSXMLRequestHandler.instance().saveFsXml(rawUri, fsxml.toString(), "PUT", true);
        }
    }
}

From source file:com.rowtheboat.input.VariableSplitInput.java

License:Open Source License

/**
 * Construct the variable split class//w w w.jav a  2 s. co  m
 * 
 * @param   file   the file from which to pull the xml workout data
 */
public VariableSplitInput(File file) throws MalformedURLException, DocumentException {

    /* Initialise the arrays */
    times = new float[10];
    timeIndexes = new int[10];

    /* Create the reader */
    SAXReader reader = new SAXReader();
    Document document = reader.read(file);

    /* Get the root element */
    root = document.getRootElement();

    /* Create the rower */
    for (Iterator i = root.elementIterator("Rower"); i.hasNext();) {

        Element rowerElement = (Element) i.next();
        ComputerRower rower = new ComputerRower(ComputerRower.VARIABLE_SPLIT);
        rower.setName(rowerElement.elementText("Name"));
    }

    /* Create the workout */
    for (Iterator i = root.elementIterator("Details"); i.hasNext();) {

        Element wElement = (Element) i.next();
        Workout workout = new Workout(Integer.parseInt(wElement.elementText("Type")));
        workout.setDate(wElement.elementText("Date"));
        if (workout.getType() == Workout.DISTANCE_WORKOUT) {
            workout.setDistance(Integer.parseInt(wElement.elementText("Distance")));
        } else {
            workout.setTime(Integer.parseInt(wElement.elementText("Time")));
        }
    }

    /* Populate the stroke times and time index arrays */
    int arrayIndex = 0;
    for (int i = 0, size = root.nodeCount(); i < size; i++) {
        Node node = root.node(i);
        if (node instanceof Element && node.getName().equals("Stroke")) {
            Element el = (Element) node;
            times[arrayIndex] = Float.parseFloat(el.elementText("Time"));
            timeIndexes[arrayIndex] = i;
            arrayIndex++;
            if (arrayIndex == times.length) {
                increaseArraySizes();
            }
        }
    }
}

From source file:com.thinkberg.moxo.dav.LockHandler.java

License:Apache License

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    FileObject object = getResourceManager().getFileObject(request.getPathInfo());

    try {/* w w w  .  j a  v  a2  s.co  m*/
        Lock lock = LockManager.getInstance().checkCondition(object, getIf(request));
        if (lock != null) {
            sendLockAcquiredResponse(response, lock);
            return;
        }
    } catch (LockException e) {
        // handle locks below
    }

    try {
        SAXReader saxReader = new SAXReader();
        Document lockInfo = saxReader.read(request.getInputStream());
        //log(lockInfo);

        Element rootEl = lockInfo.getRootElement();
        String lockScope = null, lockType = null;
        Object owner = null;
        Iterator elIt = rootEl.elementIterator();
        while (elIt.hasNext()) {
            Element el = (Element) elIt.next();
            if (TAG_LOCKSCOPE.equals(el.getName())) {
                lockScope = el.selectSingleNode("*").getName();
            } else if (TAG_LOCKTYPE.equals(el.getName())) {
                lockType = el.selectSingleNode("*").getName();
            } else if (TAG_OWNER.equals(el.getName())) {
                // TODO correctly handle owner
                Node subEl = el.selectSingleNode("*");
                if (subEl != null && TAG_HREF.equals(subEl.getName())) {
                    owner = new URL(el.selectSingleNode("*").getText());
                } else {
                    owner = el.getText();
                }
            }
        }

        log("LOCK(" + lockType + ", " + lockScope + ", " + owner + ")");

        Lock requestedLock = new Lock(object, lockType, lockScope, owner, getDepth(request),
                getTimeout(request));
        try {
            LockManager.getInstance().acquireLock(requestedLock);
            sendLockAcquiredResponse(response, requestedLock);
        } catch (LockConflictException e) {
            response.sendError(SC_LOCKED);
        } catch (IllegalArgumentException e) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        }
    } catch (DocumentException e) {
        e.printStackTrace();
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
}

From source file:com.thinkberg.webdav.LockHandler.java

License:Apache License

public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
    FileObject object = VFSBackend.resolveFile(request.getPathInfo());

    try {/*from   w ww.  j  a v a 2 s.c  o  m*/
        final LockManager manager = LockManager.getInstance();
        final LockManager.EvaluationResult evaluation = manager.evaluateCondition(object, getIf(request));
        if (!evaluation.result) {
            response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
            return;
        } else {
            if (!evaluation.locks.isEmpty()) {
                LOG.debug(String.format("discovered locks: %s", evaluation.locks));
                sendLockAcquiredResponse(response, evaluation.locks.get(0));
                return;
            }
        }
    } catch (LockConflictException e) {
        List<Lock> locks = e.getLocks();
        for (Lock lock : locks) {
            if (Lock.EXCLUSIVE.equals(lock.getType())) {
                response.sendError(SC_LOCKED);
                return;
            }
        }
    } catch (ParseException e) {
        response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED);
        return;
    }

    try {
        SAXReader saxReader = new SAXReader();
        Document lockInfo = saxReader.read(request.getInputStream());
        //log(lockInfo);

        Element rootEl = lockInfo.getRootElement();
        String lockScope = null, lockType = null;
        Object owner = null;
        Iterator elIt = rootEl.elementIterator();
        while (elIt.hasNext()) {
            Element el = (Element) elIt.next();
            if (TAG_LOCKSCOPE.equals(el.getName())) {
                lockScope = el.selectSingleNode("*").getName();
            } else if (TAG_LOCKTYPE.equals(el.getName())) {
                lockType = el.selectSingleNode("*").getName();
            } else if (TAG_OWNER.equals(el.getName())) {
                // TODO correctly handle owner
                Node subEl = el.selectSingleNode("*");
                if (subEl != null && TAG_HREF.equals(subEl.getName())) {
                    owner = new URL(el.selectSingleNode("*").getText());
                } else {
                    owner = el.getText();
                }
            }
        }

        LOG.debug("LOCK(" + lockType + ", " + lockScope + ", " + owner + ")");

        Lock requestedLock = new Lock(object, lockType, lockScope, owner, getDepth(request),
                getTimeout(request));
        try {
            LockManager.getInstance().acquireLock(requestedLock);
            sendLockAcquiredResponse(response, requestedLock);
        } catch (LockConflictException e) {
            response.sendError(SC_LOCKED);
        } catch (IllegalArgumentException e) {
            response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        }
    } catch (DocumentException e) {
        e.printStackTrace();
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
}

From source file:darks.orm.core.config.sqlmap.DMLConfigReader.java

License:Apache License

private AbstractTag parseElementTag(AbstractTag parent, Node node, Element childEl, String namesp,
        AbstractTag prevTag) throws Exception {
    if ("include".equals(node.getName())) {
        String id = childEl.attributeValue("refid");
        if (id.indexOf(".") < 0) {
            id = namesp + id;//from  w ww  .ja  v a 2 s.  c  o m
        }
        AbstractTag externTag = sqlMapConfig.getTag(id);
        if (externTag != null) {
            prevTag = externTag;
            parent.addChild(externTag);
        }
    } else {
        AbstractTag childTag = TagsFactory.createTag(childEl, prevTag);
        if (childTag != null) {
            if (childTag.parseElement(childEl)) {
                prevTag = childTag;
                parent.addChild(childTag);
                parseSqlTag(childTag, childEl, namesp);
            }
        }
    }
    return prevTag;
}

From source file:de.thischwa.pmcms.model.tool.BackupParser_1.java

License:LGPL

private void importLevel(Level parentLevel, Node levelNode) {
    Element levelElement = (Element) levelNode;
    Level level = new Level();
    level.setName(levelElement.attributeValue("name"));
    level.setTitle(levelElement.selectSingleNode("title").getText());
    level.setParent(parentLevel);/*from w w  w .  j av a2s . com*/
    parentLevel.add(level);

    @SuppressWarnings("unchecked")
    List<Node> pages = levelNode.selectNodes("page|gallery");
    for (Node node : pages) {
        if (node.getName().equals("page"))
            importPage(level, node);
        else
            importGallery(level, node);
    }

    @SuppressWarnings("unchecked")
    List<Node> subLevels = levelNode.selectNodes("level");
    for (Node node : subLevels) {
        importLevel(level, node);
    }
}

From source file:de.tudarmstadt.ukp.dkpro.wsd.io.reader.SemCorXMLReader.java

License:Apache License

@SuppressWarnings("unchecked")
private StringBuffer processSentences(JCas jCas, Element element, int offset, String idPrefix)
        throws CollectionException {
    StringBuffer sentenceText = new StringBuffer();
    for (Iterator<Element> sentenceIterator = element.elementIterator(ELEMENT_SENTENCE); sentenceIterator
            .hasNext();) {/*  ww w .j  a v  a2 s. c o m*/
        Element sentence = sentenceIterator.next();
        Sentence sentenceAnnotation = new Sentence(jCas);
        sentenceAnnotation.setBegin(offset);
        String sentenceId = sentence.attributeValue(ATTR_SNUM);
        int wordFormCount = 0;

        for (Iterator<Node> nodeIterator = sentence.nodeIterator(); nodeIterator.hasNext();) {
            Node node = nodeIterator.next();
            String nodeText = node.getText().replace('\n', ' ');
            int oldOffset = offset;
            offset += nodeText.length();
            sentenceText.append(nodeText);

            if (node.getName() == null) {
                continue;
            }

            if (node.getName().equals(ELEMENT_PUNCTUATION)) {
                logger.trace("Found punctuation " + node.getText());
                continue;
            }

            if (node.getName().equals(ELEMENT_WORDFORM) == false) {
                throw new CollectionException("unknown_element", new Object[] { node.getName() });
            }

            // Find or construct a unique ID for this word form
            wordFormCount++;
            totalWordFormCount++;
            Element wordForm = (Element) node;
            String wordFormId = wordForm.attributeValue(ATTR_ID);
            if (wordFormId == null) {
                wordFormId = idPrefix + ".s" + sentenceId + ".w" + wordFormCount;
            }
            logger.trace("Found wf id: " + wordFormId);

            String lemma = wordForm.attributeValue(ATTR_LEMMA);
            String pos = wordForm.attributeValue(ATTR_POS);

            // write DKPro Core annotations Token, Lemma, and POS
            if (shouldWriteCoreAnnotations) {
                Lemma lemmaAnno = null;
                if (lemma != null) {
                    lemmaAnno = new Lemma(jCas, offset, oldOffset + nodeText.length());
                    lemmaAnno.setValue(lemma);
                    lemmaAnno.addToIndexes();
                }

                de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS posAnno = null;
                if (pos != null) {
                    Type posTag = mappingProvider.getTagType(pos);
                    posAnno = (de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS) jCas.getCas()
                            .createAnnotation(posTag, oldOffset, oldOffset + nodeText.length());
                    posAnno.setPosValue(pos);
                    posAnno.addToIndexes();
                }

                Token tokenAnno = new Token(jCas, oldOffset, oldOffset + nodeText.length());
                tokenAnno.setLemma(lemmaAnno);
                tokenAnno.setPos(posAnno);
                tokenAnno.addToIndexes();
            }

            // Skip <wf> elements which are not marked as "done"
            if (skipUndone == true && wordForm.attributeValue(ATTR_CMD).equals(VAL_DONE) == false) {
                logger.debug("Skipping wf " + wordFormId + ": not marked as 'done'");
                continue;
            }

            // Skip <wf> elements for which semantic tags could not be
            // assigned
            if (skipUnassignable == true && wordForm.attributeValue(ATTR_OT) != null) {
                logger.debug("Skipping wf " + wordFormId + ": ot=" + wordForm.attributeValue(ATTR_OT));
                continue;
            }

            // Find the number of valid sense tags for this word form.
            // Tags with a wnsn attribute value of "0"
            // (or "-1" according to some specifications) could not be
            // mapped and so are skipped.
            String wnsn = wordForm.attributeValue(ATTR_WNSN);
            if (skipWithoutWnsn == true && wnsn == null) {
                logger.debug("Skipping wf " + wordFormId + ": no wnsn");
                continue;
            }
            int totalValidWf = 0;
            String wnsns[] = wnsn.split(";");
            for (String s : wnsns) {
                if (isValidWnsn(s)) {
                    totalValidWf++;
                }
            }
            if (skipWithoutWnsn == true && totalValidWf == 0) {
                logger.debug("Skipping wf " + wordFormId + ": wnsn=" + wordForm.attributeValue(ATTR_WNSN));
                continue;
            }

            // Skip word forms without a lemma
            if (skipWithoutLemma == true && lemma == null) {
                logger.warn("Sipping wf " + wordFormId + ": no lemma");
                continue;
            }

            // Skip word forms without a POS
            if (skipWithoutPos == true && pos == null) {
                logger.warn("Skipping " + wordFormId + ": no pos");
                continue;
            }
            try {
                pos = semCorPosToPOS(pos).toString();
            } catch (IllegalArgumentException e) {
                logger.warn("Skipping wf " + wordFormId + ": unrecognized pos=" + pos);
                continue;
            }

            // Create the necessary WSDItem and LexicalItemConstituent
            // annotations for this word form
            LexicalItemConstituent c = newLexicalItemConstituent(jCas, wordFormId, ELEMENT_WORDFORM, oldOffset,
                    nodeText.length());
            WSDItem w = newWsdItem(jCas, wordFormId, oldOffset, nodeText.length(), pos, lemma);
            w.setConstituents(new FSArray(jCas, 1));
            w.setConstituents(0, c);

            // Get an array of sense tags. Sense tags are found
            // in the lexsn attribute and are separated with
            // semicolons. Sometimes the head_word field contains
            // a superfluous character in parentheses which must
            // be removed. (These quirks are not documented in
            // the SemCor file format specification.)
            String lexsns[] = wordForm.attributeValue(ATTR_LEXSN).replaceAll("\\(.\\)", "").split(";");
            FSArray senseArray = new FSArray(jCas, totalValidWf);
            int validWfCount = 0;
            for (int i = 0; i < lexsns.length; i++) {
                if (isValidWnsn(wnsns[i])) {
                    Sense sense = new Sense(jCas);
                    sense.setId(lemma + "%" + lexsns[i]);
                    sense.setConfidence(1.0);
                    sense.addToIndexes();
                    senseArray.set(validWfCount++, sense);
                }
            }

            WSDResult wsdResult = new WSDResult(jCas, oldOffset, oldOffset + nodeText.length());
            wsdResult.setWsdItem(w);
            wsdResult.setSenses(senseArray);
            wsdResult.setSenseInventory(senseInventory);
            wsdResult.setDisambiguationMethod(DISAMBIGUATION_METHOD_NAME);
            wsdResult.addToIndexes();
        }

        sentenceAnnotation.setEnd(offset);
        sentenceAnnotation.addToIndexes();
    }
    return sentenceText;
}

From source file:de.tudarmstadt.ukp.dkpro.wsd.io.reader.WebCAGeXMLReader.java

License:Apache License

@SuppressWarnings("unchecked")
private StringBuffer processText(JCas jCas, Element text) throws CollectionException {
    StringBuffer documentText = new StringBuffer();
    int offset = 0;

    // Loop over all nodes to get the document text in order
    for (Iterator<Node> nodeIterator = text.nodeIterator(); nodeIterator.hasNext();) {

        Node node = nodeIterator.next();
        String nodeText = node.getText().replace('\n', ' ');
        String nodeName = node.getName();

        // TODO: For now we ignore satellites. We should add support for
        // them./*from w w  w  .  j  a  v a  2 s. com*/
        if (nodeName == null || nodeName.equals(ELEMENT_SAT)) {
            offset += nodeText.length();
            documentText.append(nodeText);
            continue;
        }

        // If the node is a head, create a LexicalItemConstituent and a
        // WSDItem
        else if (nodeName.equals(ELEMENT_HEAD)) {
            Element head = (Element) node;
            String headId = head.attributeValue(ATTR_ID);
            String lemma = head.attributeValue(ATTR_LEMMA);

            logger.trace("Reading instance " + headId);

            // Skip word forms without a POS
            String pos = head.attributeValue(ATTR_POS);
            if (pos == null) {
                logger.warn("No POS provided for " + headId + "; skipping");
                continue;
            }
            try {
                pos = webCAGePosToPOS(pos).toString();
            } catch (IllegalArgumentException e) {
                logger.warn("Unrecognized POS " + pos + " provided for " + headId + "; skipping");
                continue;
            }

            // Create the necessary WSDItem and LexicalItemConstituent
            // annotations for this word form
            LexicalItemConstituent c = newLexicalItemConstituent(jCas, headId, ELEMENT_HEAD, offset,
                    nodeText.length());
            WSDItem w = newWsdItem(jCas, headId, offset, nodeText.length(), pos, lemma);
            w.setConstituents(new FSArray(jCas, 1));
            w.setConstituents(0, c);

            // Get an array of lexical unit IDs (LUIDs). LUIDs are found
            // in the luids attribute and are separated with
            // # characters.
            String luids[] = head.attributeValue(ATTR_LUIDS).split("#");
            FSArray senseArray = new FSArray(jCas, luids.length);
            for (int i = 0; i < luids.length; i++) {
                Sense sense = new Sense(jCas);
                sense.setId(luids[i].substring(1));
                sense.setConfidence(1.0);
                sense.addToIndexes();
                senseArray.set(i, sense);
            }

            WSDResult wsdResult = new WSDResult(jCas);
            wsdResult.setWsdItem(w);
            wsdResult.setSenses(senseArray);
            wsdResult.setSenseInventory(senseInventory);
            wsdResult.setDisambiguationMethod(DISAMBIGUATION_METHOD_NAME);
            wsdResult.addToIndexes();

        }

        // If the node is any other element, something is wrong
        else if (node.getNodeTypeName().equals("Entity") == false) {
            throw new CollectionException("unknown_element", new Object[] { node.getName() });
        }

        offset += nodeText.length();
        documentText.append(nodeText);
    }
    return documentText;
}

From source file:de.tudarmstadt.ukp.dkpro.wsd.senseval.reader.Semeval1AWReader.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//from w ww  . j  a v  a  2  s . c o m
public void getNext(JCas jCas) throws IOException, CollectionException {
    int offset = 0, numSentences = 0;
    String s = "";
    Element text = textIterator.next();

    for (Iterator<Element> sentenceIterator = text.elementIterator(SENTENCE_ELEMENT_NAME); sentenceIterator
            .hasNext();) {

        Element sentence = sentenceIterator.next();
        Sentence sentenceAnnotation = new Sentence(jCas);
        sentenceAnnotation.setBegin(offset);

        for (Iterator<Node> nodeIterator = sentence.nodeIterator(); nodeIterator.hasNext();) {

            Node node = nodeIterator.next();
            String nodeText = node.getText().replace('\n', ' ');

            // If the node is a head, create a LexicalItemConstituent and a
            // WSDItem
            if (node.getName() != null && node.getName().equals(HEAD_ELEMENT_NAME)) {
                Element head = (Element) node;
                String id = head.attributeValue(ID_ATTRIBUTE_NAME);

                LexicalItemConstituent c = newLexicalItemConstituent(jCas, id, LIC_TYPE_HEAD, offset,
                        nodeText.length());
                WSDItem w = newWsdItem(jCas, id, LIC_TYPE_HEAD, offset, nodeText.length(),
                        head.attributeValue(POS_ATTRIBUTE_NAME), head.attributeValue(LEMMA_ATTRIBUTE_NAME));
                w.setConstituents(new FSArray(jCas, 1));
                w.setConstituents(0, c);
            } else if (node.getName() != null) {
                throw new CollectionException("unknown_element", new Object[] { node.getName() });
            }

            offset += nodeText.length();
            s += nodeText;
        }

        sentenceAnnotation.setEnd(offset);
        sentenceAnnotation.addToIndexes();
        numSentences++;
    }

    // The Semeval-1 DTD requires each text to have at least one sentence
    if (numSentences == 0) {
        throw new CollectionException("element_not_found",
                new Object[] { SENTENCE_ELEMENT_NAME, TEXT_ELEMENT_NAME });
    }

    jCas.setDocumentText(s);

    try {
        setDocumentMetadata(jCas, text.attributeValue(ID_ATTRIBUTE_NAME));
    } catch (URISyntaxException e) {
        throw new IOException(e);
    }

    textCount++;
}

From source file:de.tudarmstadt.ukp.dkpro.wsd.senseval.reader.Semeval2AWReader.java

License:Apache License

@SuppressWarnings("unchecked")
@Override/*  ww w .  j  a  va 2 s.  c om*/
public void getNext(JCas jCas) throws IOException, CollectionException {
    int offset = 0;
    String s = "";
    Element text = textIterator.next();

    for (Iterator<Element> sentenceIterator = text.elementIterator(SENTENCE_ELEMENT_NAME); sentenceIterator
            .hasNext();) {

        Map<String, WSDItem> wsdItems = new HashMap<String, WSDItem>();
        Map<String, LexicalItemConstituent> lics = new HashMap<String, LexicalItemConstituent>();
        Map<String, String> sats = new HashMap<String, String>();
        Element sentence = sentenceIterator.next();
        Sentence sentenceAnnotation = new Sentence(jCas);
        sentenceAnnotation.setBegin(offset);

        // Loop over all nodes to get the document text in order
        for (Iterator<Node> nodeIterator = sentence.nodeIterator(); nodeIterator.hasNext();) {

            Node node = nodeIterator.next();
            String nodeText = node.getText().replace('\n', ' ');
            String nodeName = node.getName();

            if (nodeName == null) {
                offset += nodeText.length();
                s += nodeText;
                continue;
            }

            // If the node is a satellite, create a LexicalItemConstituent
            if (nodeName.equals(SATELLITE_ELEMENT_NAME)) {
                String id = ((Element) node).attributeValue(ID_ATTRIBUTE_NAME);
                lics.put(id,
                        newLexicalItemConstituent(jCas, id, LIC_TYPE_SATELLITE, offset, nodeText.length()));
            }

            // If the node is a head, create a LexicalItemConstituent and a WSDItem
            else if (nodeName.equals(HEAD_ELEMENT_NAME)) {
                Element head = (Element) node;
                String id = head.attributeValue(ID_ATTRIBUTE_NAME);
                String satellites = head.attributeValue(SATELLITES_ATTRIBUTE_NAME);

                lics.put(id, newLexicalItemConstituent(jCas, id, LIC_TYPE_HEAD, offset, nodeText.length()));
                wsdItems.put(id, newWsdItem(jCas, id, LIC_TYPE_HEAD, offset, nodeText.length(),
                        head.attributeValue(POS_ATTRIBUTE_NAME), head.attributeValue(LEMMA_ATTRIBUTE_NAME)));

                if (satellites != null)
                    sats.put(id, satellites);
            }

            // If the node is any other element, something is wrong
            else if (node.getNodeTypeName().equals("Entity") == false) {
                throw new CollectionException("unknown_element", new Object[] { node.getName() });
            }

            offset += nodeText.length();
            s += nodeText;
        }

        // Add a sentence annotation
        sentenceAnnotation.setEnd(offset);
        sentenceAnnotation.addToIndexes();

        populateLexicalItemConstituents(jCas, wsdItems, lics, sats);
    }

    jCas.setDocumentText(s);

    try {
        setDocumentMetadata(jCas, text.attributeValue(ID_ATTRIBUTE_NAME));
    } catch (URISyntaxException e) {
        throw new IOException(e);
    }

    textCount++;
}