static private void parseHeader ( String base , XMLStreamReader rdr , List < String > cols , List < String > md ) throws XMLStreamException , SparqlException { logger . debug ( "xml:base is initially {}" , base ) ; base = getBase ( base , rdr ) ; testOpen ( rdr , rdr . nextTag ( ) , HEAD , "Missing header from XML results" ) ; base = getBase ( base , rdr ) ; boolean endedVars = false ; int eventType ; while ( ( eventType = rdr . nextTag ( ) ) != END_ELEMENT || ! nameIs ( rdr , HEAD ) ) { if ( eventType == START_ELEMENT ) { if ( nameIs ( rdr , VARIABLE ) ) { if ( endedVars ) throw new SparqlException ( "Encountered a variable after header metadata" ) ; String var = rdr . getAttributeValue ( null , "name" ) ; if ( var != null ) cols . add ( var ) ; else logger . warn ( "<variable> element without 'name' attribute" ) ; } else if ( nameIs ( rdr , LINK ) ) { String b = getBase ( base , rdr ) ; // Copy to a new var since we're looping. String href = rdr . getAttributeValue ( null , HREF ) ; if ( href != null ) md . add ( resolve ( b , href ) ) ; else logger . warn ( "<link> element without 'href' attribute" ) ; endedVars = true ; } } } // ending on </head>. next() should be <results> or <boolean> testClose ( rdr , eventType , HEAD , "Unexpected element in header: " + rdr . getLocalName ( ) ) ; }
Parse the &lt ; head&gt ; element with the variables and metadata .