xsl:number的高性能替代品 [英] high-performance alternative to xsl:number

查看:64
本文介绍了xsl:number的高性能替代品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试为

大型XML文档中的每个标签''foo''分配一个唯一的ID。目前我正在这样做:


< xsl:variable name =" UniqueId">

< xsl:number count =" FOO" level =" any" />

< / xsl:variable>


但是使用.Net framework 1.1(使用XPathDocument)它很慢对于

大文件(比如100mb,里面有100,000个foo标签)。当我说

很慢的时候,我说的是天,我希望它需要几分钟!!


我见过的唯一纯XSL替代方案是使用position()。但是,

< footags可以出现在文档中的不同级别(并且

可能是嵌套的),所以我认为这个位置很难

使用。 XSLT中还有其他模板执行其他

处理。


Id'我生成的不必是连续的但是他们必须增加

你进一步下载文件


有没有任何简单可靠的解决方案,或者我应该只是咬紧牙关

并使用C#预处理文档以在运行之前放入这些ID中

其余的转换


谢谢


Andy

Hi,

I am trying to allocate a unique ID to every instance of tag ''foo'' in a
large XML document. currently I''m doing this:

<xsl:variable name="UniqueId">
<xsl:number count="foo" level="any"/>
</xsl:variable>

but with .Net framework 1.1 (using XPathDocument) it is very slow for
large documents (say 100mb with 100,000 foo tags in it). when I say
very slow, I am talking days and I would like it to take minutes !!

the only pure XSL alternative I''ve seen is to use position(). however,
the <footags can occur at different levels within the document (and
might be nested), so I''m thinking that position would be difficult to
use. There are also other templates within the XSLT which perform other
processing.

the Id''s I generate don''t have to be contiguous but they must increase
the further you go down the document

is there any simple reliable solution, or should I just bite the bullet
and pre-process the document with C# to put in these Ids before running
the rest of the transform

Thanks

Andy

推荐答案

aj****@blueyonder.co.uk 写道:
aj****@blueyonder.co.uk wrote:

我试图为每个标签''foo'的实例分配一个唯一的ID '在一个

的大型XML文档中。目前我正在这样做:


< xsl:variable name =" UniqueId">

< xsl:number count =" FOO" level =" any" />

< / xsl:variable>


但是使用.Net framework 1.1(使用XPathDocument)它很慢对于

大文件(比如100mb,里面有100,000个foo标签)。当我说

非常慢时,我说的是几天,我希望它需要几分钟!
I am trying to allocate a unique ID to every instance of tag ''foo'' in a
large XML document. currently I''m doing this:

<xsl:variable name="UniqueId">
<xsl:number count="foo" level="any"/>
</xsl:variable>

but with .Net framework 1.1 (using XPathDocument) it is very slow for
large documents (say 100mb with 100,000 foo tags in it). when I say
very slow, I am talking days and I would like it to take minutes !!



可以使用generate-id()生成唯一ID,但格式为

不是数字而是字符串后面的字符串XML ID要求。


-

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


Martin Honnen写道:
Martin Honnen wrote:
aj****@blueyonder.co.uk 写道:
aj****@blueyonder.co.uk wrote:

我试图在

大型XML文档中为标签foo的每个实例分配一个唯一的ID。目前我正在这样做:


< xsl:variable name =" UniqueId">

< xsl:number count =" FOO" level =" any" />

< / xsl:variable>


但是使用.Net framework 1.1(使用XPathDocument)它很慢对于

大文件(比如100mb,里面有100,000个foo标签)。当我说

非常慢时,我说的是几天,我希望它需要几分钟!
I am trying to allocate a unique ID to every instance of tag ''foo'' in a
large XML document. currently I''m doing this:

<xsl:variable name="UniqueId">
<xsl:number count="foo" level="any"/>
</xsl:variable>

but with .Net framework 1.1 (using XPathDocument) it is very slow for
large documents (say 100mb with 100,000 foo tags in it). when I say
very slow, I am talking days and I would like it to take minutes !!



可以使用generate-id()生成唯一ID,尽管格式为

不是数字而是字符串后面的字符串XML ID要求。


A unique id can be generated with generate-id() although the format will
not be a number but rather a string following the XML ID requirements.



感谢马丁,我不知道那个。


严格我的ID不一定是一个数字,但是我需要

这些ID在排序时按文档顺序排列。我猜这不太可能是
(标准肯定不能保证)。所以

很遗憾我不认为这是我可以用的这个

时间

thanks martin, I didn''t know about that one.

strictly my ID doesn''t have to be a number, but I would require that
the IDs are lexically in document order when sorted. I guess this is
unlikely (and the standard certainly doesn''t guarantee it). so
unfortunately I don''t think it''s something I will be able to use this
time

< br>

aj****@blueyonder.co.uk 写道:

[...]
aj****@blueyonder.co.uk wrote:
[...]

Id'我生成的不必连续但他们必须增加

进一步你下去文件
the Id''s I generate don''t have to be contiguous but they must increase
the further you go down the document



其他人已经为原始请求提供了许多解决方案,

但是我觉得我应该考虑问题这个。这可能是一个坏主意

通过添加另一个含义来侵入ID空间。一个ID就是一个ID,仅仅是一个ID,仅此而已:它只是说这是我,我是独一无二的。


试图制作ID值意味着另外几乎总是错误的,并且几乎总是糟糕的数据设计的标志。它就像

创建客户编号的传统方式:区域的两位数,

行业代码的三位数,然后是一个破折号,因为我们< 1954年接管的
总是使用它们,然后用一个数字和4个

数字,然后是一个校验位,最后是一个唯一数字。序列

数。会计办公室和营销办公室*喜欢*这样做,当他们应该做的事情就是在其他地方记录所有这些信息

并为客户分配一个任意的唯一ID。 br />

如果您的客户需要一个序列指示器,请创建一个属性并且

使它反映
$ b中每个foo元素的数字序列位置$ b文件。如果数据是长期重要的,只需将身份证作为ID

,你的继任者会感谢你。


另一方面,如果喜欢大量的商业数据,那么在做出决定的情况下,10-15分钟只需要很多重要的时间,那么任何旧的垃圾都会这么做

满足眼前的条件:-)


/// Peter

-

XML FAQ: http://xml.silmaril.ie


这篇关于xsl:number的高性能替代品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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