GMLDictionaryReader { public Definition read() throws XMLStreamException { Definition definition = null; QName elName = xmlStream.getName(); if ( new QName( gmlNs, "Dictionary" ).equals( elName ) || new QName( gmlNs, "DefinitionCollection" ).equals( elName ) ) { definition = readDictionary(); } else if ( new QName( gmlNs, "Definition" ).equals( elName ) ) { definition = readDefinition(); } else { String msg = "Invalid gml:Definition element: " + xmlStream.getName() + "' is not a GML definition (or dictionary or definition collection) element."; throw new XMLParsingException( xmlStream, msg ); } return definition; } GMLDictionaryReader( GMLVersion version, XMLStreamReader xmlStream, GmlDocumentIdContext idContext ); Definition read(); Dictionary readDictionary();  }
@Test public void testReadExampleDictionary() throws XMLStreamException, FactoryConfigurationError, IOException { URL url = GMLDictionaryReaderTest.class.getResource( "../misc/dictionary/example_dictionary.gml" ); XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( url.toString(), url.openStream() ); xmlStream.nextTag(); GMLDictionaryReader dictReader = new GMLDictionaryReader( GML_30, xmlStream, new GmlDocumentIdContext( GML_30 ) ); Dictionary dict = (Dictionary) dictReader.read(); assertEquals( "CodeLists", dict.getId() ); assertEquals( 2, dict.size() ); assertEquals( "XP_HorizontaleAusrichtung", dict.get( 0 ).getId() ); assertEquals( "XP_BedeutungenBereich", dict.get( 1 ).getId() ); }
@Test public void testWriteExampleDictionary() throws XMLStreamException, FactoryConfigurationError, IOException { URL url = GMLDictionaryReaderTest.class.getResource( "../misc/dictionary/example_dictionary.gml" ); XMLStreamReader xmlStream = XMLInputFactory.newInstance().createXMLStreamReader( url.toString(), url.openStream() ); xmlStream.nextTag(); GMLDictionaryReader dictReader = new GMLDictionaryReader( GML_30, xmlStream, new GmlDocumentIdContext( GML_30 ) ); Dictionary dict = (Dictionary) dictReader.read(); XMLMemoryStreamWriter xmlWriter = new XMLMemoryStreamWriter(); GMLDictionaryWriter writer = new GMLDictionaryWriter( GML_30, new IndentingXMLStreamWriter( xmlWriter.getXMLStreamWriter() )); writer.write( dict ); xmlWriter.getXMLStreamWriter().close(); }