Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8a15dc
commit 0e18e55
Showing
3 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.xembly; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import javax.xml.transform.OutputKeys; | ||
import javax.xml.transform.Transformer; | ||
|
||
public interface Output { | ||
|
||
|
||
void prepareTransformer(final Transformer transformer); | ||
|
||
|
||
final class Document implements Output { | ||
|
||
private final Map<String, String> properties; | ||
|
||
public Document() { | ||
this((Document.defaultProperties())); | ||
} | ||
|
||
public Document(final Map<String, String> properties) { | ||
this.properties = properties; | ||
} | ||
|
||
@Override | ||
public void prepareTransformer(final Transformer transformer) { | ||
this.properties.entrySet().stream() | ||
.forEach((e) -> transformer.setOutputProperty(e.getKey(), e.getValue())); | ||
} | ||
|
||
private static Map<String, String> defaultProperties() { | ||
final HashMap<String, String> res = new HashMap<>(); | ||
res.put(OutputKeys.INDENT, "yes"); | ||
res.put(OutputKeys.ENCODING, "UTF-8"); | ||
return res; | ||
} | ||
} | ||
|
||
final class Node implements Output { | ||
|
||
@Override | ||
public void prepareTransformer(final Transformer transformer) { | ||
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters