WMTSCapabilitiesAdapter extends OWSCommon110CapabilitiesAdapter { Layer parseLayer( XMLStreamReader xmlStream ) throws XMLStreamException { nextElement( xmlStream ); skipToRequiredElementOnSameLevel( xmlStream, IDENTIFIER ); String identifier = xmlStream.getElementText().trim(); nextElement( xmlStream ); skipToRequiredElementOnSameLevel( xmlStream, STYLE ); List<Style> styles = new ArrayList<Style>(); while ( xmlStream.isStartElement() && STYLE.equals( xmlStream.getName() ) ) { styles.add( parseStyle( xmlStream ) ); nextElement( xmlStream ); } skipToRequiredElementOnSameLevel( xmlStream, FORMAT ); List<String> formats = new ArrayList<String>(); while ( xmlStream.isStartElement() && FORMAT.equals( xmlStream.getName() ) ) { formats.add( xmlStream.getElementText().trim() ); nextElement( xmlStream ); } List<String> infoFormats = new ArrayList<String>(); while ( xmlStream.isStartElement() && INFO_FORMAT.equals( xmlStream.getName() ) ) { infoFormats.add( xmlStream.getElementText().trim() ); nextElement( xmlStream ); } skipToRequiredElementOnSameLevel( xmlStream, TILE_MATRIX_SET_LINK ); List<String> tileMatrixSets = new ArrayList<String>(); while ( xmlStream.isStartElement() && TILE_MATRIX_SET_LINK.equals( xmlStream.getName() ) ) { tileMatrixSets.add( parseTileMatrixSetLink( xmlStream ) ); nextElement( xmlStream ); } while ( !xmlStream.isEndElement() || !LAYER.equals( xmlStream.getName() ) ) { xmlStream.next(); } return new Layer( identifier, styles, formats, infoFormats, tileMatrixSets ); } WMTSCapabilitiesAdapter(); List<Layer> parseLayers(); List<TileMatrixSet> parseTileMatrixSets();  }
@Test public void testParseLayer() throws Exception { XMLStreamReader xmlStream = getResourceXmlStreamReader( "wmts100_layer.xml" ); assertEquals( START_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "Layer" ), xmlStream.getName() ); Layer layer = adapter.parseLayer( xmlStream ); assertEquals( END_ELEMENT, xmlStream.getEventType() ); assertEquals( new QName( WMTS_100_NS, "Layer" ), xmlStream.getName() ); assertEquals( "utah_ortho", layer.getIdentifier() ); List<Style> styles = layer.getStyles(); assertEquals( 1, styles.size() ); Style style = styles.get( 0 ); assertEquals( "default", style.getIdentifier() ); assertEquals( true, style.isDefault() ); List<String> formats = layer.getFormats(); assertEquals( 1, formats.size() ); assertEquals( "image/png", formats.get( 0 ) ); List<String> tileMatrixSets = layer.getTileMatrixSets(); assertEquals( 1, tileMatrixSets.size() ); assertEquals( "Satellite_Provo", tileMatrixSets.get( 0 ) ); }