Q:

JAXB - Parse XML list sequentially (one by one)

I have to parse XML which root element is a list:
<SomeObjectsCollection>
  <SomeObject><!-- content1 --></SomeObject>
  <SomeObject><!-- content2 --></SomeObject>
  <SomeObject><!-- content3 --></SomeObject>
    <!--  and hundreds more -->
</SomeObjectsCollection>

I don't want to parse whole XML to memory for performance reasons.  I would rather write something like Iterable<SomeObjetType> that wouldn't enforce user to keep whole unmarshaled list in memory, just process it one by one. 
So far I wrote such class which implements Iterable<SomeObject> and my own Iterator inside:
public class SomeObjectsIterableParser implements Iterable<SomeObjectType> {

  private final Unmarshaller jaxbUnmarshaller;
  private final XMLStreamReader xmlReader;

  public SomeObjectsIterableParser(Schema schema, java.io. Reader xmlStringReader) throws ExtractorException {
    try {
      jaxbUnmarshaller = JAXBContext.newInstance(SomeObjectType.class).createUnmarshaller();
      xmlReader = XMLInputFactory.newFactory().createXMLStreamReader(xmlStringReader);
    } catch (JAXBException | XMLStreamException e) {
      throw new ExtractorException("Could not create jaxbUnmarshaller", e);
    }
    jaxbUnmarshaller.setSchema(schema); //turns on schema validation

    //Move reader to first occurence of SomeObject - really necessary? 
    try {
      while (xmlReader.hasNext()) {
        if (! xmlReader.isStartElement() || ! xmlReader.getLocalName().equals("SomeObject"))
          xmlReader.next();
        else break;
      }
    } catch (XMLStreamException e) {
      e.printStackTrace();
    }

  }

  @Override
  public Iterator<SomeObjectType> iterator() {
    return new MyIterator();
  }

  class MyIterator implements Iterator<SomeObjectType> {

    @Override
    public boolean hasNext() {
      try {
        return xmlReader.hasNext();
      } catch (XMLStreamException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    public SomeObjectType next() {
      try {
        return (SomeObjectType) jaxbUnmarshaller.unmarshal(xmlReader);
      } catch (JAXBException | XMLStreamException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("Not supported yet");
    }
  }
}

I receive exception in next() method with message: org.xml.sax. SAXParseException; lineNumber: 2; columnNumber: 17; cvc-elt.1: Cannot find the declaration of element 'SomeObject'. 
What am I doing wrong? 

A:

I found the article that describes what I want to do.  As a result I wrote such code:
public class SomeObjectsIterableParser implements Iterable<SomeObjectType> {

  private final Unmarshaller jaxbUnmarshaller;
  private final XMLStreamReader xmlReader;

  public SomeObjectsIterableParser(Schema schema, Reader SomeObjectResponse) throws ExtractorException {
    try {
      jaxbUnmarshaller = JAXBContext.newInstance(SomeObjectType.class).createUnmarshaller();
      xmlReader = XMLInputFactory.newFactory().createXMLStreamReader(SomeObjectResponse);
    } catch (JAXBException | XMLStreamException e) {
      throw new ExtractorException("Could not create jaxbUnmarshaller", e);
    }
    //jaxbUnmarshaller.setSchema(schema); //schema can handle only root element
    advanceReaderToFirstProfile();
  }

  private void advanceReaderToFirstProfile() {
    try {
      xmlReader.nextTag();
      while(!xmlReader.getLocalName().equals("SomeObject")) {
        xmlReader.nextTag();
      }
    } catch (XMLStreamException e) {
      e.printStackTrace();
    }
  }

  @Override
  public Iterator<SomeObjectType> iterator() {
    return new MyIterator();
  }

  class MyIterator implements Iterator<SomeObjectType> {

    @Override
    public boolean hasNext() {
      try {
        if (xmlReader.isWhiteSpace() && xmlReader.hasNext()) {
          //ommit witespaces
          xmlReader.nextTag();
        }
      } catch (XMLStreamException e) {
        throw new RuntimeException(e);
      }
      return xmlReader.isStartElement() 
          && xmlReader.getLocalName().equals("SomeObject");
    }

    @Override
    public SomeObjectType next() {
      try {
        JAXBElement<SomeObjectType> element = jaxbUnmarshaller.unmarshal(xmlReader, SomeObjectType.class);
        return element.getValue();
      } catch (JAXBException | XMLStreamException e) {
        throw new RuntimeException(e);
      }
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException("Not supported yet");
    }
  }
}

Be aware of 3 thinks:

Schema validation can not be applied to non-root element.  There is related question here. 
Use syntax:
JAXBElement<SomeObjectType> element = jaxbUnmarshaller.unmarshal(xmlReader, SomeObjectType.class);
instead of
(SomeObjectType) jaxbUnmarshaller.unmarshal(xmlReader);. 
Otherwise you receive an exception:  

java.lang. RuntimeException: javax.xml.bind. UnmarshalException  

with linked exception:
  [com.sun.istack.internal. SAXParseException2; lineNumber: 2; columnNumber: 22; unexpected element (uri:"", local:"SomeObject").  Expected elements are (none)]

Handle exceptions more carefully than in the example.  Iterable and Iterator interfaces does not allow you to throw non-runtime exceptions.