Skip to content

Commit 20b6152

Browse files
authored
Merge pull request #1615 from harawata/substitute-var-in-cdata
Support variable substitution in CDATA of included `<sql />`
2 parents 07b5344 + 1cd35f9 commit 20b6152

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/org/apache/ibatis/builder/xml/XMLIncludeTransformer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void applyIncludes(Node source, final Properties variablesContext, boole
8181
for (int i = 0; i < children.getLength(); i++) {
8282
applyIncludes(children.item(i), variablesContext, included);
8383
}
84-
} else if (included && source.getNodeType() == Node.TEXT_NODE
84+
} else if (included && (source.getNodeType() == Node.TEXT_NODE || source.getNodeType() == Node.CDATA_SECTION_NODE)
8585
&& !variablesContext.isEmpty()) {
8686
// replace variables in text node
8787
source.setNodeValue(PropertyParser.parse(source.getNodeValue(), variablesContext));

src/test/java/org/apache/ibatis/submitted/include_property/Mapper.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2009-2018 the original author or authors.
4+
Copyright 2009-2019 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -26,9 +26,9 @@
2626
col_c
2727
</sql>
2828

29-
<sql id="colsSuffix">
29+
<sql id="colsSuffix"><![CDATA[
3030
col_${suffix}
31-
</sql>
31+
]]></sql>
3232

3333
<sql id="colsPrefix">
3434
${prefix}a

0 commit comments

Comments
 (0)