大型XML文件和分页,可以吗? [英] Large XML Files and Pagination, is it possible?

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

问题描述

在计算机上本地打开非常大的XML文件时,几乎可以肯定的是,打开该文件需要一段时间-这通常意味着您的计算机由于认为没有响应而被锁定.

When opening very large XML files locally, on your machine, it's almost a certainty that it will take an age for that file to open - it can often mean your computer locks down because it thinks it's not responding.

如果您为用户提供他们使用的相当复杂的数据库或系统的XML备份,这将是一个问题-他们能够打开大型备份(更不用说使用它们)的可能性很小.

This is an issue if you serve users XML backups of rather complex databases or systems they use - the likehood of them being able to open large backups, let alone use them, is slim.

我使用XSLT向用户提供可读的备份.以这种相同的方式,有可能一次只提取一个页面,以防止一次读取整个文件,从而导致上述问题.

I use XSLT to present readable backups to users. In this same way, would it be possible to pull only a page at a time of data, to prevent the entire file from being read in one go, thus causing the issues above.

我想答案是肯定的-,但我想知道是否还有其他人也看到过同样的问题并解决了.

I imagine the answer is simply a no - but I would like to know if anyone else has seen the same issues and resolved them.

注意:这仅在本地计算机上,它不需要互联网连接.如果使事情变得简单,则可以使用JavaScript.

Note: This is on a local machine only, it must not require an internet connection. JavaScript can be used if it makes things easier.

推荐答案

使用XSLT进行分页是可能的,但可能不会导致预期的结果:为了使XSLT正常工作,必须将整个XML文档解析为DOM树.

Pagination with XSLT is possible, but will probably not lead to the desired results: For XSLT to work, the whole XML document must be parsed into a DOM tree.

您可以做的是尝试流式转换: http://stx.sourceforge.net/

What you could do, is experiment with streaming transformations: http://stx.sourceforge.net/

或者您可以在使用XSLT进行处理之前对大型XML文件进行预处理,以将其切成较小的位.为此,我将使用 XMLStarlet

Or you could preprocess the large XML file to cut it up into smaller bits before processing with XSLT. For this I'd use a command line tool like XMLStarlet

这篇关于大型XML文件和分页,可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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