Skip to content

Commit bf61b05

Browse files
authored
Merge pull request #14 from ndw/single-char
Fix bug in processing a line containing a single non-whitespace character
2 parents b119e3d + ea10d00 commit bf61b05

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
basename=sinclude
22
sincludeTitle=Saxon XInclude
3-
sincludeVersion=5.2.0
3+
sincludeVersion=5.2.1
44

55
saxonVersion=11.5

src/main/java/com/nwalsh/sinclude/XInclude.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ public XdmNode process(XdmNode node) throws XPathException {
467467
while (last > first && lines[pos].charAt(last) == ' ') {
468468
last--;
469469
}
470-
if (first != last) {
471-
ReceiverUtils.handleCharacters(receiver, lines[pos].substring(first, last+1));
472-
}
470+
// There must be at least one non-space character on the line, so
471+
// this is always going to be a legal substring
472+
ReceiverUtils.handleCharacters(receiver, lines[pos].substring(first, last+1));
473473
}
474474
}
475475
// Only output newlines between lines, not after the last line

src/test/java/com/nwalsh/sinclude/FakeDocumentResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public class FakeDocumentResolver implements DocumentResolver {
172172
" </section>\n" +
173173
"</doc>\n");
174174
xmlMap.put("trimtext.xml", "<doc xmlns:xi='http://www.w3.org/2001/XInclude'>\n" +
175-
"<xi:include href='four.txt' parse='text' fragid='L2-L4'/>\n" +
175+
"<xi:include href='four.txt' parse='text' fragid='L2-L6'/>\n" +
176176
"</doc>\n");
177177
}
178178

@@ -182,7 +182,7 @@ public class FakeDocumentResolver implements DocumentResolver {
182182
textMap.put("one.txt", "This is line one.\n");
183183
textMap.put("two.txt", "\n\n\n\n\n\n\n\n\nThis is line 10.\n\n\n\n\nThis is line 15.");
184184
textMap.put("three.xml", "<doc>Document three.</doc>");
185-
textMap.put("four.txt", " Four leading blanks\n Three leading blanks\n Six leading blanks\nNo leading blanks");
185+
textMap.put("four.txt", " Four leading blanks\n {\n Three leading blanks\n }\n Four leading blanks\nNo leading blanks");
186186
}
187187

188188
private static Map<String, String> expandedMap = null;
@@ -318,7 +318,7 @@ public class FakeDocumentResolver implements DocumentResolver {
318318
"</doc>\n");
319319
expandedMap.put("selfrefloop.xml", "<doc/>");
320320
expandedMap.put("trimtext.xml", "<doc xmlns:xi='http://www.w3.org/2001/XInclude'>\n" +
321-
"Three leading blanks\n Six leading blanks\nNo leading blanks\n\n" +
321+
"{\n Three leading blanks\n}\n Four leading blanks\nNo leading blanks\n\n" +
322322
"</doc>\n");
323323

324324
}

0 commit comments

Comments
 (0)