GetCapabilitiesXMLParser extends OWSCommonXMLAdapter { public GetCapabilities parse100() throws XMLParsingException { String updateSequence = rootElement.getAttributeValue( new QName( "updateSequence" ) ); String[] versions = getNodesAsStrings( rootElement, new XPath( "ows:AcceptVersions/ows:Version/text()", nsContext ) ); List<String> sections = parseSections( OWS_PREFIX ); List<OMElement> formatElements = getElements( rootElement, new XPath( "ows:AcceptFormats/ows:OutputFormat", nsContext ) ); List<String> formats = new ArrayList<String>( formatElements.size() ); for ( OMElement formatElement : formatElements ) { formats.add( formatElement.getText() ); } List<String> languages = null; String languageString = rootElement.getAttributeValue( new QName( "language" ) ); if ( languageString != null ) { languages = Arrays.asList( languageString.split( "," ) ); } return new GetCapabilities( null, Arrays.asList( versions ), sections, formats, updateSequence, languages ); } GetCapabilitiesXMLParser();  GetCapabilitiesXMLParser( OMElement rootElement ); GetCapabilities parse100(); GetCapabilities parse110(); GetCapabilities parse200();  }
@Test public void testParsing100() { URL docURL = GetCapabilitiesXMLParserTest.class.getResource( "../capabilities/GetCapabilitiesOWS100.xml" ); GetCapabilitiesXMLParser parser = new GetCapabilitiesXMLParser(); parser.load( docURL ); GetCapabilities request = parser.parse100(); assertNotNull( request ); assertNotNull( request.getAcceptVersions() ); assertEquals( 2, request.getAcceptVersions().size() ); assertEquals( Version.parseVersion( "1.0.0" ), request.getAcceptVersionsAsVersions().get( 1 ) ); assertEquals( Version.parseVersion( "1.1.0" ), request.getAcceptVersionsAsVersions().get( 0 ) ); assertNotNull( request.getSections() ); assertEquals( 3, request.getSections().size() ); assertTrue( request.getSections().contains( "ServiceIdentification" ) ); assertTrue( request.getSections().contains( "ServiceProvider" ) ); assertTrue( request.getSections().contains( "OperationsMetadata" ) ); assertNotNull( request.getAcceptFormats() ); assertEquals( 1, request.getAcceptFormats().size() ); assertEquals( "text/xml", request.getAcceptFormats().iterator().next() ); assertNull( request.getUpdateSequence() ); }