diff --git a/pom.xml b/pom.xml
index 6424423..376fdee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,7 @@
org.jdom
jdom2
- 2.0.5
+ 2.0.6
commons-cli
diff --git a/skel_common/readme_modders.txt b/skel_common/readme_modders.txt
index 2cf97ff..b98b004 100644
--- a/skel_common/readme_modders.txt
+++ b/skel_common/readme_modders.txt
@@ -205,18 +205,24 @@ Advanced XML
Raw XML
+ This feature was a workaround for a bug that was fixed in Slipstream 1.7.
+
+ The bug caused Slipstream to trim off leading/trailing space in XML values.
+ This was problematic for "misc.xml" (in FTL 1.5.4-1.5.13), which defined
+ phrases for localization. Some phrases had spaces, which led to ugly results
+ in-game if trimmed.
+
FTL is quirky. Occasionally you may need to include non-standard XML in a
- mod without elaborate parsing. For instance, "misc.xml" defines phrases
- for localization, which may begin/end with a space. Normally, this
- whitespace would be trimmed away, leading to ugly results in-game.
+ mod without elaborate parsing.
If your mod has a file named "misc.xml.rawappend", the content of that
file will be tacked onto the end of "misc.xml". Line-endings and encoding
- will be standardized, but Slipstream will make no attempt to
- (mis)understand the tags of either file.
+ will be standardized. Root tags, if present, will be removed before
+ appending and restored after, but Slipstream will make no attempt to
+ (mis)understand the tags of either file for advanced modding.
You can still override existing tags by adding your own with the same
- name attribute, since FTL honors the last it sees.
+ 'name' attribute, since FTL honors the last it sees.
Similarly a file named "misc.xml.rawclobber" will entirely replace the
original "misc.xml".
diff --git a/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java b/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java
index 00f4693..1818037 100644
--- a/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java
+++ b/src/main/java/net/vhati/modmanager/core/SloppyXMLOutputProcessor.java
@@ -37,6 +37,7 @@ import org.jdom2.util.NamespaceStack;
*/
public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor {
+
// Copied from AbstractXMLOutputProcessor in JDOM 2.0.5, with modification.
@Override
protected void printElement( Writer out, FormatStack fstack, NamespaceStack nstack, Element element ) throws IOException {
@@ -79,13 +80,15 @@ public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor {
}
try {
+ // Always null!? And what about other TextModes?
final String space = element.getAttributeValue( "space", Namespace.XML_NAMESPACE );
- if ( "default".equals(space) ) {
+ if ( "default".equals( space ) ) {
fstack.setTextMode( fstack.getDefaultMode() );
}
- else if ( "preserve".equals(space) ) {
+ else if ( "preserve".equals( space ) ) {
fstack.setTextMode( Format.TextMode.PRESERVE );
}
+ //if ( space != null ) System.out.println( space );
Walker walker = buildWalker( fstack, content, true );
if ( !walker.hasNext() ) {
@@ -154,6 +157,7 @@ public class SloppyXMLOutputProcessor extends AbstractXMLOutputProcessor {
*/
public static void sloppyPrint( Document doc, Writer writer, String encoding ) throws IOException {
Format format = Format.getPrettyFormat();
+ format.setTextMode( Format.TextMode.PRESERVE ); // Permit leading/trailing space.
format.setExpandEmptyElements( false );
format.setOmitDeclaration( false );
format.setIndent( "\t" );