@Override
  public StartElement startElement(final StartElement element) throws XMLStreamException {
    final String curPath = parser.getCurPath();
    if (this.inside) {
      this.deepLevel++;
      writeElement(element);

      final int attCount = element.getAttributeCount();
      for (int i = 0; i < attCount; i++) {
        final Attribute curAtt = element.getAttribute(i);
        writeAttribute(
            curAtt.getNamespace(),
            element.getLocalName(),
            curAtt.getLocalName(),
            curAtt.getValue(),
            curAtt.getPrefix());
      }
    } else {
      if (curPath.endsWith("components/component")) {
        final int indexObjid = element.indexOfAttribute(null, "objid");
        final int indexHref = element.indexOfAttribute(Constants.XLINK_NS_URI, "href");
        if (!(indexObjid > -1 && element.getAttribute(indexObjid).getValue().length() > 0
            || indexHref > -1
                && Utility.getId(element.getAttribute(indexHref).getValue()).length() > 0)) {

          // start new component if there is no ID
          final ByteArrayOutputStream out = new ByteArrayOutputStream();

          this.writer = XmlUtility.createXmlStreamWriter(out);
          outputStreams.add(out);

          this.inside = true;
          this.deepLevel++;
          writeElement(element);

          final int attCount = element.getAttributeCount();
          for (int i = 0; i < attCount; i++) {
            final Attribute curAtt = element.getAttribute(i);
            writeAttribute(
                curAtt.getNamespace(),
                element.getLocalName(),
                curAtt.getLocalName(),
                curAtt.getValue(),
                curAtt.getPrefix());
          }
        }
      }
    }
    return element;
  }
  @Override
  public StartElement startElement(final StartElement element)
      throws TripleStoreSystemException, WebserverSystemException, InvalidContentException {
    final String curPath = parser.getCurPath();
    if (curPath.startsWith(this.componentPath) && curPath.equals(this.componentPath)) {
      // do my job
      // save componentId
      final int indexObjid = element.indexOfAttribute(null, "objid");
      final int indexHref = element.indexOfAttribute(Constants.XLINK_NS_URI, "href");
      if (indexObjid >= 0 || indexHref >= 0) {
        final String componentId =
            indexObjid >= 0
                ? element.getAttribute(indexObjid).getValue()
                : Utility.getId(element.getAttribute(indexHref).getValue());

        if (componentId.length() > 0) {
          // check if component exists
          boolean componentExists = false;
          final List<String> existingComponents =
              TripleStoreUtility.getInstance().getComponents(this.itemId);
          for (final String existingComponent : existingComponents) {
            if (existingComponent.equals(componentId)) {
              componentExists = true;
              break;
            }
          }
          if (!componentExists) {
            throw new InvalidContentException(
                "Component with id "
                    + componentId
                    + " does not exist in item "
                    + this.itemId
                    + '.');
          }
        }
      }
    }
    return element;
  }