Xml extends XmlGenerator implements ProductionVisitor<SAXException>, TermVisitor<SAXException> { public static void write( Grammar grammar, Writer writer ) throws TransformerException { generate( new Xml( grammar ), writer ); } private  Xml( Grammar grammar ); static void write( Grammar grammar, Writer writer ); static void write( Grammar grammar, OutputStream stream ); static void write( Grammar grammar, Output output ); static void main( String... args ); @Override void visitProduction( Production production ); @Override void visitAlternatives( Alternatives alternatives ); @Override void visitSequence( Sequence sequence ); @Override void visitLiteral( Literal value ); @Override void visitCharacters( CharacterSet characters ); @Override void visitNonTerminal( NonTerminal nonTerminal ); @Override void visitOptional( Optional optional ); @Override void visitRepetition( Repetition repetition ); @Override void visitEpsilon();  }
@Test public void shouldProduceLiteral() throws TransformerException { StringBuilder builder = new StringBuilder(); Output.Readable output = Output.output( builder ); Grammar build = Grammar.grammar( "foo" ).production( "bar", Grammar.literal( "literal" ) ).build( Grammar.Builder.Option.ALLOW_ROOTLESS ); Xml.write( build, output ); assertThat( builder.toString(), containsString( "case-sensitive=\"true\"" ) ); }
@Test public void shouldProduceCaseInsensitive() throws TransformerException { StringBuilder builder = new StringBuilder(); Output.Readable output = Output.output( builder ); Grammar build = Grammar.grammar( "foo" ).production( "bar", Grammar.caseInsensitive( "literal" ) ).build( Grammar.Builder.Option.ALLOW_ROOTLESS ); Xml.write( build, output ); assertThat( builder.toString(), containsString( "case-sensitive=\"false\"" ) ); }
@Test public void shouldGenerateCypher() throws Exception { Output.Readable out = stringBuilder(); Grammar first = fixture.grammarResource( "/cypher.xml" ); Xml.write( first, out ); testRoundTrip( Grammar.parseXML( out.reader() ) ); }