Skip to content

Commit

Permalink
Various fixes contributed by Tomek Grabon. Include DefaultMdxParser.c…
Browse files Browse the repository at this point in the history
…up in source distro; add xercesImpl.jar to path; in XMLA driver, explicitly pass <Catalog>; encode characters <, >, single and double quote in XML strings.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@80 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Mar 14, 2008
1 parent 567c871 commit af33fc9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 2 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ${jar-jdk14.file}"/>
<pathelement location="${ant.home}/lib/ant.jar"/>
<pathelement location="${lib.dir}/log4j-1.2.9.jar"/>
<pathelement location="${lib.dir}/javacup.jar"/>
<pathelement location="${lib.dir}/xercesImpl.jar"/>
<pathelement location="${testlib.dir}/junit.jar"/>
<pathelement location="${testlib.dir}/servlet.jar"/>
</path>
Expand Down Expand Up @@ -197,6 +198,7 @@ ${jar-jdk14.file}"/>
prefix="${dist.name}"
includes="
${src.dir}/**/*.java,
${src.dir}/**/*.cup,
${testsrc.dir}/**/*.java,
doc/**/*.css,
doc/**/*.png,
Expand Down
31 changes: 20 additions & 11 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ public String generateRequest(
{
final String dataSourceInfo =
context.olap4jConnection.getDataSourceInfo();
final String catalog =
context.olap4jConnection.getCatalog();
final String content = "Data";
final String encoding = proxy.getEncodingCharsetName();
final StringBuilder buf = new StringBuilder(
Expand Down Expand Up @@ -551,6 +553,9 @@ public String generateRequest(
+ " <DataSourceInfo>");
buf.append(dataSourceInfo);
buf.append("</DataSourceInfo>\n"
+ " <Catalog>");
buf.append(catalog);
buf.append("</Catalog>\n"
+ " <Content>" + content + "</Content>\n"
+ " </PropertyList>\n"
+ " </Properties>\n"
Expand All @@ -563,22 +568,26 @@ public String generateRequest(
/**
* Encodes a string for use in an XML CDATA section.
*
* <p>TODO use an XML serialiser or handle these too:
* quote (") "
* apostrophe (') &apos;
* ampersand (&) &amp;
* less than (<) &lt;
* greater than (>) &gt;
*
* @param value to be xml encoded
* @return an XML encode string or the value is not required.
*/
private static String xmlEncode(String value){
if (value.indexOf('&') == -1) {
return value;
} else {
return value.replace("&", "&amp;");
if (value.indexOf('&') >= 0) {
value = value.replace("&", "&amp;");
}
if (value.indexOf('<') >= 0) {
value = value.replace("<", "&lt;");
}
if (value.indexOf('>') >= 0) {
value = value.replace(">", "&gt;");
}
if (value.indexOf('"') >= 0) {
value = value.replace("\"", "&quot;");
}
if (value.indexOf('\'') >= 0) {
value = value.replace("'", "&apos;");
}
return value;
}

// ~ inner classes --------------------------------------------------------
Expand Down

0 comments on commit af33fc9

Please sign in to comment.