1111import java .io .InputStream ;
1212import java .io .OutputStream ;
1313import java .net .URL ;
14- import java .text .Normalizer ;
15- import java .util .regex .Pattern ;
1614
1715import javax .xml .transform .Result ;
1816import javax .xml .transform .Source ;
3533public class ApacheFOPHeroldTest {
3634 private String [] inputUrls = {// @formatter:off
3735 "http://www.baeldung.com/2011/10/20/bootstraping-a-web-application-with-spring-3-1-and-java-based-configuration-part-1/" ,
38- // "http://www.baeldung.com/2011/10/25/building-a-restful-web-service-with-spring-3-1-and-java-based-configuration-part-2/",
39- // "http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/",
40- // "http://www.baeldung.com/spring-security-basic-authentication",
41- // "http://www.baeldung.com/spring-security-digest-authentication",
42- // "http://www.baeldung.com/2011/11/20/basic-and-digest-authentication-for-a-restful-service-with-spring-security-3-1/",
36+ "http://www.baeldung.com/2011/10/25/building-a-restful-web-service-with-spring-3-1-and-java-based-configuration-part-2/" ,
37+ "http://www.baeldung.com/2011/10/31/securing-a-restful-web-service-with-spring-security-3-1-part-3/" ,
38+ "http://www.baeldung.com/spring-security-basic-authentication" ,
39+ "http://www.baeldung.com/spring-security-digest-authentication" ,
40+ "http://www.baeldung.com/2011/11/20/basic-and-digest-authentication-for-a-restful-service-with-spring-security-3-1/" ,
4341 //"http://www.baeldung.com/spring-httpmessageconverter-rest",
4442 //"http://www.baeldung.com/2011/11/06/restful-web-service-discoverability-part-4/",
4543 //"http://www.baeldung.com/2011/11/13/rest-service-discoverability-with-spring-part-5/",
@@ -56,6 +54,8 @@ public class ApacheFOPHeroldTest {
5654 private String xmlInput = "src/test/resources/input.xml" ;
5755 private String xmlOutput = "src/test/resources/output.xml" ;
5856
57+ // tests
58+
5959 @ Test
6060 public void whenTransformFromHeroldToPDF_thenCorrect () throws Exception {
6161 final int len = inputUrls .length ;
@@ -78,7 +78,7 @@ private void fromHTMLTOXMLUsingHerold(final String input, final boolean append)
7878 final DocBookTransformer transformer = new DocBookTransformer ();
7979 transformer .setScript (script );
8080
81- transformer .convert (getInputStream (input ), new FileOutputStream (xmlInput , append ));
81+ transformer .convert (getInputStream (input ), new FileOutputStream (xmlInput , append ));
8282 }
8383
8484 private Document fromXMLFileToFO () throws Exception {
@@ -115,19 +115,20 @@ private InputStream getInputStream(final String input) throws IOException {
115115 return url .openStream ();
116116 }
117117
118- private void fixXML (final String input , final String output ) throws IOException {
118+ private void fixXML (final String input , final String output ) throws IOException {
119119 final BufferedReader reader = new BufferedReader (new FileReader (input ));
120120 final FileWriter writer = new FileWriter (output );
121121 String line = reader .readLine ();
122122 int count = 0 ;
123- while (line != null ){
124- line = line .replaceAll ("[^\\ x00-\\ x7F]" , "" );
125-
126- if (line .contains ("info>" )){
123+ while (line != null ) {
124+ line = line .replaceAll ("”" , "\" " );
125+ line = line .replaceAll ("“" , "\" " );
126+ // line = line.replaceAll("[^\\x00-\\x7F]", "");
127+
128+ if (line .contains ("info>" )) {
127129 writer .write (line .replace ("info>" , "section>" ));
128- }
129- else if (!((line .startsWith ("<?xml" ) || line .startsWith ("<article" ) || line .startsWith ("</article" )) && count > 4 )){
130- writer .write (line .replaceAll ("xml:id=\" " , "xml:id=\" " +count ));
130+ } else if (!((line .startsWith ("<?xml" ) || line .startsWith ("<article" ) || line .startsWith ("</article" )) && count > 4 )) {
131+ writer .write (line .replaceAll ("xml:id=\" " , "xml:id=\" " + count ));
131132 }
132133 writer .write ("\n " );
133134
0 commit comments