XML,XSLT和JavaScript [英] XML, XSLT and JavaScript

查看:103
本文介绍了XML,XSLT和JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦搞清楚如何使网站的页面加载架构。

其基本思想是,我会用XSLT present但它不是做它与XSL标签,我会做它用JavaScript的经典方法。因此,每一个环节应该是指一个JavaScript函数,将改变页面的内容和菜单。

我为什么要这样来做,是有让JavaScript的动态显示使用第一,初始的XML文件,而不是做一个完整的服务器请求的特定页面中提供的数据中的每个页面的选项的原因,它只是有太多的缺点。

中的基本问题是,具有后在网上搜索一个解决方案来访问使用JavaScript文件的基础性的XML,我只能找到解决方案来访问外部XML文件。

我当然可以只打印所有的XML数据转换为JavaScript数组中的文件头完全申报,但我相信这将是一个非常,非常讨厌的解决方案。和丑陋,对于这个问题。

我的提问,因此有:

  • 它甚至有可能做什么,我 想什么?
  • 难道是搜索引擎友好的让所有 该网站的网页的内容装 最初在XML文件?

我的选择是动态加载使用AJAX对需求的特定页面的内容。然而,我发现很难找到一个方式,将是最SEO友好。我无法想象,一个搜索引擎会执行任何JavaScript。

我很抱歉,如果这还不清楚,但它真的吓到我了。
先谢谢了。

解决方案
  

它甚至有可能做我在想什么呢?

当然。

  

这将是搜索引擎友好有网站的页面的内容全部初始加载XML文件中?

没有,那将是总的疯狂。

  

我无法想象,一个搜索引擎会执行任何JavaScript。

嗯,相当。它也pretty的坏辅助功能:非JS浏览器,浏览器或与JS实现略有差别(例如新保留字),导致你的脚本有一个错误,热潮!没有任何页面。除非你通过散列链接提供合适的导航,实用性将是可怕的了。

全中的JavaScript页​​面内容创作可以为原始Web应用程序(臭名昭著,GMail的)是有用的,但对于一个内容驱动的站点,将在很大程度上灾难性的。你会基本上是必须建立在客户端的JS浏览器和所有其他代理服务器端的同一页面,此时你已经失去了做这一切在客户端的优势。

可能更好地做到这一点,像这样:主要是基于HTML的,但客户端渐进增强做有用的任务,如检查服务器的更新,并打印这个问题有了新答案发布

I'm having some trouble figuring out how to make the "page load" architecture of a website.

The basic idea is, that I would use XSLT to present it but instead of doing it the classic way with the XSL tags I would do it with JavaScript. Each link should therefore refer to a JavaScript function that would change the content and menus of the page.

The reason why I want to do it this way, is having the option of letting JavaScript dynamically show each page using the data provided in the first, initial XML file instead of making a "complete" server request for the specific page, which simply has too many downsides.

The basic problem of that is, that after having searched the web for a solution to access the "underlying" XML of the document with JavaScript, I only find solutions to access external XML files.

I could of course just "print" all the XML data into a JavaScript array fully declared in the document header, but I believe this would be a very, very nasty solution. And ugly, for that matter.

My questions therefore are:

  • Is it even possible to do what I'm thinking of?
  • Would it be SEO-friendly to have all the website pages' content loaded initially in the XML file?

My alternative would be to dynamically load the specific page's content using AJAX on demand. However, I find it difficult to find a way that would be the least SEO-friendly. I can't imagine that a search engine would execute any JavaScript.

I'm very sorry if this is unclear, but it's really freaking me out.
Thanks in advance.

解决方案

Is it even possible to do what I'm thinking of?

Sure.

Would it be SEO-friendly to have all the website pages' content loaded initially in the XML file?

No, it would be total insanity.

I can't imagine that a search engine would execute any JavaScript.

Well, quite. It's also pretty bad for accessibility: non-JS browsers, or browsers with a slight difference in JS implementation (eg new reserved words) that causes your script to have an error and boom! no page. And unless you provide proper navigation through hash links, usability will be terrible too.

All-JavaScript in-page content creation can be useful for raw web applications (infamously, GMail), but for a content-driven site it would be largely disastrous. You'd essentially have to build up the same pages from the client side for JS browsers and the server side for all other agents, at which point you've lost the advantage of doing it all on the client.

Probably better to do it like SO: primarily HTML-based, but with client-side progressive enhancement to do useful tasks like checking the server for updates and printing the "this question has new answers" announce.

这篇关于XML,XSLT和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆