更新 1
現在、テキストを WT プロジェクトにロードしている方法を次に示します。
wApp->require("ace.js");
//orignal XML, reads in incorrectly on one line
//std::string data = ReadFile("Q:\\settings.xml");
//XML after being formatted in notepad to look like xml, reads in correctly
//std::string data = ReadFile("Q:\\settings.txt");
//changed extension back to XML, edited in notepad++ to XML format, reads in correctly
std::string data = ReadFile("Q:\\settings_from_text.xml");
//test xml tag, reads in correctly
//std::string data = "<tag_1>some tag content</tag_1>";
//test xml tag with newline, reads in incorrectly on one line, doesnt read newline
//std::string data = "<tag_1>some tag content</tag_1>\n<tag_1>some tag content</tag_1>";
_ace_editor = new WText(data, Wt::PlainText);
//_ace_editor->setText(data);
_ace_editor->setInline(false);
// A WContainerWidget is rendered as a div
_ace_editor->resize(1000, 500);
std::string editor_ref = _ace_editor->jsRef(); // is a text string that will be the element when executed in JS
std::string command =
editor_ref + "._ace_editor = ace.edit(" + editor_ref + ");" +
editor_ref + "._ace_editor.setTheme(\"ace/theme/chrome\");" +
editor_ref + "._ace_editor.getSession().setMode(\"ace/mode/xml\");";// +
//editor_ref + "._ace_editor.setValue(\"" + data + "\");";
_ace_editor->doJavaScript(command);
また、ここに ReadFile 関数があります
std::ifstream in(path, std::ios::in | std::ios::binary);
if(in)
{
std::string contents;
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();
return(contents);
}
throw(errno);
元の投稿
いくつかの XML ファイルを、 WT ( http://www.webtoolkit.eu/wt?wtd =rqBfShGlNupXgK3M1sWOxUk1Loz3BsW0 ) ページ。問題は、何らかの理由で XML ファイルのすべてのタグがロードから省略されていることです。例: 次の内容の XML ファイル
<?xml version="1.0"?>
<settings>
<tag_1>some tag content</tag_1>
<tag_2/>
</settings>
としてロードされます
some tag content
タグの内容だけでなく、XML ファイル全体が必要です。
少し調査を行った後、さまざまなフォーラムで同じことを尋ねる他のかなりの数の人々を見つけましたが、これまでに試したことはすべてうまくいきませんでした。
これには、Ace モードを XML に設定する、ace ウィンドウに設定する前に別のコンテナーにテキストを読み込もうとする、配色を変更する、別の方法でファイルを解析するなどが含まれます。
私はVisual Studio 2010を使用しています。デバッグから、ファイルがすべてのタグを含む文字列に完全に読み込まれることがわかりますが、Aceウィンドウに設定された後、それらは省略されます。