/**
   * Helper Method to check for existence of given attribute
   *
   * @param r The {@link XMLStreamReader}
   * @param attrName The searched attributes Names
   * @param nsMap The nsMap to search in
   * @param needed Flag indicating if attribute is needed or not
   * @return found QName
   * @throws MalformedTLGLSyntaxException
   */
  private static QName getQNAttribute(
      XMLStreamReader r, String attrName, INamespaceMap<String, String> nsMap, boolean needed)
      throws MalformedTLGLSyntaxException {
    if (r.getAttributeValue(null, attrName) != null) {
      List<String> splitted = Arrays.asList(r.getAttributeValue(null, attrName).split(":"));

      QName newQName = new QName(nsMap.get(splitted.get(0)), splitted.get(1), splitted.get(0));
      return newQName;
    } else {
      if (needed) {
        throw new MalformedTLGLSyntaxException("Attribute " + attrName + " is not set !!");
      } else {
        return null;
      }
    }
  }
 /**
  * Helper Method to check for existence of given attribute
  *
  * @param r The {@link XMLStreamReader}
  * @param attrName The searched attributes Names
  * @param nsMap The nsMap to search in
  * @param needed Flag indicating if attribute is needed or not
  * @return found List<QName>
  * @throws MalformedTLGLSyntaxException
  */
 private static List<QName> getQNsAttribute(
     XMLStreamReader r, String attrName, INamespaceMap<String, String> nsMap, boolean needed)
     throws MalformedTLGLSyntaxException {
   if (r.getAttributeValue(null, attrName) != null) {
     List<String> qnStrings = Arrays.asList(r.getAttributeValue(null, attrName).split("[ ]+"));
     List<QName> qNames = new ArrayList<QName>();
     for (String string : qnStrings) {
       List<String> splitted = Arrays.asList(string.split(":"));
       QName newQName = new QName(nsMap.get(splitted.get(0)), splitted.get(1), splitted.get(0));
       qNames.add(newQName);
     }
     return qNames;
   } else {
     if (needed) {
       throw new MalformedTLGLSyntaxException("Attribute " + attrName + " is not set !!");
     } else {
       return null;
     }
   }
 }