Skip to content

Commit

Permalink
normalizing values prior to substitution...
Browse files Browse the repository at this point in the history
... and updating example generated output .docx
  • Loading branch information
danhaywood committed Nov 9, 2012
1 parent ce5ea67 commit c2524ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
.project
.classpath
.settings/
target/
*.class

# Package Files #
*.jar
*.war
*.ear

Generated.docx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ public static String textValueOf(Element htmlElement) {
return null;
}
Text htmlText = (Text) content;
return htmlText.getValue();
return normalized(htmlText.getValue());
}


private static String normalized(String value) {
String replaceAll = value.replaceAll("\\s+", " ");
return replaceAll;
}

public static Function<Element, String> textValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void main(String[] args) throws Exception {
URL templateUrl = Resources.getResource(DocxServiceDemo.class, "TypicalDocument.docx");
ByteArrayInputStream docxTemplateIs = new ByteArrayInputStream(Resources.toByteArray(templateUrl));

java.io.File targetFile = new java.io.File(System.getProperty("user.dir") + "/target/Generated.docx");
java.io.File targetFile = new java.io.File(System.getProperty("user.dir") + "/Generated.docx");
FileOutputStream targetFos = new FileOutputStream(targetFile);

DocxService docxService = new DocxService();
Expand Down
Binary file not shown.

0 comments on commit c2524ba

Please sign in to comment.