类似的时间线。 XML 文件有问题

发布于 2024-09-16 15:08:36 字数 2642 浏览 9 评论 0原文

我在网上搜索如何做时间线。我找到了我喜欢的这个: http://www.simile-widgets.org/timeline/< /a>

所以我尝试遵循他们的教程,可以在这里找到: http://simile.mit .edu/wiki/How_to_Create_Timelines

我按照教程进行操作,因此代码是相同的,但这里是:

<script>
   var tl;
function onLoad() {
var eventSource = new Timeline.DefaultEventSource();

var bandInfos = [
Timeline.createBandInfo({
    eventSource:    eventSource,
    date:           "Jun 28 2006 00:00:00 GMT",

    width:          "70%", 
    intervalUnit:   Timeline.DateTime.MONTH, 
    intervalPixels: 100
}),
Timeline.createBandInfo({
    eventSource:    eventSource,
    date:           "Jun 28 2006 00:00:00 GMT",

    width:          "30%", 
    intervalUnit:   Timeline.DateTime.YEAR, 
    intervalPixels: 200
})
  ];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;

tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
Timeline.loadXML("test.xml", function(xml, url) { eventSource.loadXML(xml, url); });

}

var resizeTimerID = null;
function onResize() {
if (resizeTimerID == null) {
    resizeTimerID = window.setTimeout(function() {
        resizeTimerID = null;
        tl.layout();
    }, 500);
}
}

</script>
<body onload="onLoad();" onresize="onResize();">
<div id="my-timeline" style="height: 150px; border: 1px solid #aaa"></div>
</body>

我在 test.xml 中

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <?xml-stylesheet type="text/css" href="/TBDBsite/media/timeline.css"?>
 <data>
<event 
    start="May 28 2006 09:00:00 GMT"
    end="Jun 15 2006 09:00:00 GMT"
    isDuration="true"
    title="Writing Timeline documentation"
    image="http://simile.mit.edu/images/csail-logo.gif"
    >
    A few days to write some documentation for <a href="http://simile.mit.edu/timeline/">Timeline</a>.
    </event>

<event 
    start="Jun 16 2006 00:00:00 GMT"
    end="Jun 26 2006 00:00:00 GMT"
    title="Friend's wedding"
    >
    I'm not sure precisely when my friend's wedding is.
    </event>

<event 
    start="Aug 02 2006 00:00:00 GMT"
    title="Trip to Beijing"
    link="http://travel.yahoo.com/"
    >
    Woohoo!
    </event>
 </data>

遇到了 LOAD XML 问题,我将其 XML 示例文件保存在模板所在的位置,但是当我刷新页面时,出现此错误:

无法从 test.xml 加载数据 xml
未找到

我想知道是否有人知道原因或解决这个问题。我的想法是将数据保存到某个 XML 文件中,但也许这不是最好的解决方案。
如果有人有更好的想法来制定时间线,我也将不胜感激。

谢谢!

I was searching through the web how to do time lines. I found this one that I like: http://www.simile-widgets.org/timeline/

So I try to follow their tutorial, which can be found here: http://simile.mit.edu/wiki/How_to_Create_Timelines

I following the tutorial so the code is the same but here it goes:

<script>
   var tl;
function onLoad() {
var eventSource = new Timeline.DefaultEventSource();

var bandInfos = [
Timeline.createBandInfo({
    eventSource:    eventSource,
    date:           "Jun 28 2006 00:00:00 GMT",

    width:          "70%", 
    intervalUnit:   Timeline.DateTime.MONTH, 
    intervalPixels: 100
}),
Timeline.createBandInfo({
    eventSource:    eventSource,
    date:           "Jun 28 2006 00:00:00 GMT",

    width:          "30%", 
    intervalUnit:   Timeline.DateTime.YEAR, 
    intervalPixels: 200
})
  ];
bandInfos[1].syncWith = 0;
bandInfos[1].highlight = true;

tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
Timeline.loadXML("test.xml", function(xml, url) { eventSource.loadXML(xml, url); });

}

var resizeTimerID = null;
function onResize() {
if (resizeTimerID == null) {
    resizeTimerID = window.setTimeout(function() {
        resizeTimerID = null;
        tl.layout();
    }, 500);
}
}

</script>
<body onload="onLoad();" onresize="onResize();">
<div id="my-timeline" style="height: 150px; border: 1px solid #aaa"></div>
</body>

And the test.xml

 <?xml version="1.0" encoding="ISO-8859-1"?>
 <?xml-stylesheet type="text/css" href="/TBDBsite/media/timeline.css"?>
 <data>
<event 
    start="May 28 2006 09:00:00 GMT"
    end="Jun 15 2006 09:00:00 GMT"
    isDuration="true"
    title="Writing Timeline documentation"
    image="http://simile.mit.edu/images/csail-logo.gif"
    >
    A few days to write some documentation for <a href="http://simile.mit.edu/timeline/">Timeline</a>.
    </event>

<event 
    start="Jun 16 2006 00:00:00 GMT"
    end="Jun 26 2006 00:00:00 GMT"
    title="Friend's wedding"
    >
    I'm not sure precisely when my friend's wedding is.
    </event>

<event 
    start="Aug 02 2006 00:00:00 GMT"
    title="Trip to Beijing"
    link="http://travel.yahoo.com/"
    >
    Woohoo!
    </event>
 </data>

I'm having a problem with LOAD XML, I save their XML example file in the same place that the template but when I refresh the page I get this error:

Failed to load data xml from test.xml
NOT FOUND

I would like to known if anyone knowns why or to solve this. My idea was to save my data into some XML file but perhaps it isn't the best solution.
If someone has better ideias to make time lines I would also appreciate.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

じее 2024-09-23 15:08:36

回复相当晚,但错误是由包含 xml 声明的数据文件引起的。时间轴小部件仅以以下开头的 xml 除外

<data>

The reply, is rather late, but the error results from the data file including the xml declaration. The timeline widget only excepts an xml commencing with

<data>
ゃ人海孤独症 2024-09-23 15:08:36

您是否尝试过使用 xml 的完整 url 路径?类似于“http://localhost/text.xml”..或者可能是相对路径“./test .xml”

have you tried with a complete url path for the xml? something like "http://localhost/text.xml".. or maybe a relative path "./test.xml"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文