1.1 --- a/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java Sat Sep 06 21:14:48 2014 +0200
1.2 +++ b/java/alt2xml-in-ini/src/cz/frantovo/alt2xml/in/ini/Reader.java Sat Sep 06 21:15:47 2014 +0200
1.3 @@ -19,6 +19,7 @@
1.4
1.5 import cz.frantovo.alt2xml.AbstractAlt2XmlReader;
1.6 import cz.frantovo.alt2xml.in.Alt2ContentHandler;
1.7 +import static cz.frantovo.alt2xml.in.Functions.encodeXmlName;
1.8 import java.io.BufferedReader;
1.9 import java.io.IOException;
1.10 import java.io.InputStreamReader;
1.11 @@ -129,14 +130,19 @@
1.12 }
1.13
1.14 },
1.15 - SECTION("\\s*\\[\\s*(?<name>[^\\s\\]]+)\\s*\\]\\s*") {
1.16 + SECTION("\\s*\\[\\s*(?<name>[^\\]\\]]+)\\s*\\]\\s*") {
1.17 @Override
1.18 public void processLine(LineContext lc, FileContext fc) throws SAXException {
1.19 - // TODO: escaping for section names with spaces
1.20 - String name = lc.matcher.group("name");
1.21 + String originalName = lc.matcher.group("name");
1.22 + String encodedName = encodeXmlName(originalName);
1.23 +
1.24 + if (!encodedName.equals(originalName)) {
1.25 + log.log(Level.FINE, "Line {0}: section name „{1} was encoded to „{2}““", new Object[]{fc.lineNumber, originalName, encodedName});
1.26 + }
1.27 +
1.28 fc.outputEndSection(fc.lastSection);
1.29 - fc.outputStartSection(name);
1.30 - fc.lastSection = name;
1.31 + fc.outputStartSection(encodedName);
1.32 + fc.lastSection = encodedName;
1.33 }
1.34
1.35 },