code: public static Pipe newPipe(final XMLStreamReader parser)
      {
          final XmlInput xmlInput = new XmlInput(parser);
          return new Pipe()
          {
              protected Input begin(Pipe.Schema<?> pipeSchema) throws IOException
              {
                  //final String simpleName = pipeSchema.wrappedSchema.messageName();
  
                  try
                  {
                      if(parser.nextTag() != START_ELEMENT || 
                              !pipeSchema.wrappedSchema.messageName().equals(parser.getLocalName()))
                      {
                          throw new XmlInputException("Expected token START_ELEMENT: " + 
                                  pipeSchema.wrappedSchema.messageName());
                      }
                      
                      if(parser.nextTag() == END_ELEMENT)
                      {
                          //if(!simpleName.equals(parser.getLocalName()))
                          //    throw new XmlInputException("Expecting token END_ELEMENT: " + 
                          //            simpleName);
                          
                          // empty message;
                          return null;
                      }
                  }
                  catch(XMLStreamException e)
                  {
                      throw new XmlInputException(e);
                  }
                  
                  return xmlInput;
              }
              
              protected void end(Pipe.Schema<?> pipeSchema, Input input, 
                      boolean cleanupOnly) throws IOException
              {
                  if(cleanupOnly)
                  {
                      try
                      {
                          parser.close();
                      }
                      catch (XMLStreamException e)
                      {
                          // ignore
                      }
                      return;
                  }
                  
                  assert input == xmlInput;
                  
                  //final String simpleName = pipeSchema.wrappedSchema.messageName();
                  //final String localName = parser.getLocalName();
                  
                  try
                  {
                      parser.close();
                  }
                  catch (XMLStreamException e)
                  {
                      // end of pipe transfer ... ignore
                  }
                  
                  /*if(!simpleName.equals(localName))
                  {
                      throw new XmlInputException("Expecting token END_ELEMENT: " + 
                              simpleName);
                  }*/
              }
          };
      }
docs: Creates an xml pipe from an {@link XMLStreamReader}.