XSL排序问题 [英] XSL sorting problem
问题描述
我遇到了XSL排序问题。问题是我需要创建
a 2列表,所以我正在使用它。
< xsl:apply-templates select =" //照片[position()mod 2 = 1]">
< / xsl:apply-templates>
带模板
< xsl:template match =" //照片">
.....
< / xsl:template>
当我想按日期排序照片时出现问题(字段名称
拍摄)
我试过这个
< xsl:apply-templates select =" // Photo [position()mod 2 = 1]">
< xsl:sort select ="采取/>
< / xsl:apply-templates>
使用模板
< xsl:模板匹配=" //照片>
.....
< / xsl:template>
但是你可以看到它按照日期排序第一列照片
但第二列没有排序,因为第二列是生产的
使用:
follow-sibling :: * / XXXXX
当我尝试这个时:
< xsl:apply-templates select =" / /照片">
< xsl:sort select =" Taken" />
< / xsl:apply-templates>
使用模板
< xsl:template match =" // Photo [position()mod 2 = 1]">
。 ....
< / xsl:template>
表格没问题,但打印出来自某些照片的所有数据
节点位于页面顶部。
ie。
181001047_20050627_001.jpgtmb_001047_20050627_001。 jpga27 / 06/2005
12:00:00
AM22001047_20050628_002.jpgtmb_001047_20050628_002 .jpg2planks28 / 06/2005
12:00:00 AM44001047_20050628_004。 jpgtmb_001047_20050628_004 .jpg4
28/06/2005 12:00:00
AM66001047_20050628_006.jpgtmb_001047_20050628_006 .jpg28 / 06/2005
12:00: 00 AM
有人能告诉我如何解决这个问题。
I have a problem with XSL sorting. The problem is that I need to create
a 2 column table so I am using this.
<xsl:apply-templates select="//Photo[position()mod 2=1]">
</xsl:apply-templates>
With template
<xsl:template match="//Photo">
.....
</xsl:template>
The problem arises when I want to sort the Photos by date (field name
Taken)
I tried this
<xsl:apply-templates select="//Photo[position()mod 2=1]">
<xsl:sort select="Taken"/>
</xsl:apply-templates>
With template
<xsl:template match="//Photo">
.....
</xsl:template>
but as you could see it is sorting the first columns of photos by date
but the second column is not sorted, as the second column is produced
using :
following-sibling::*/XXXXX
When I tried this:
<xsl:apply-templates select="//Photo">
<xsl:sort select="Taken"/>
</xsl:apply-templates>
With template
<xsl:template match="//Photo[position()mod 2=1]">
.....
</xsl:template>
The table is fine but its printing out all of the data from some Photo
nodes at the top of the page.
ie.
181001047_20050627_001.jpgtmb_001047_20050627_001. jpga27/06/2005
12:00:00
AM22001047_20050628_002.jpgtmb_001047_20050628_002 .jpg2planks28/06/2005
12:00:00 AM44001047_20050628_004.jpgtmb_001047_20050628_004 .jpg4
28/06/2005 12:00:00
AM66001047_20050628_006.jpgtmb_001047_20050628_006 .jpg28/06/2005
12:00:00 AM
Can someone tell me how to solve this problem.
推荐答案
任何人?
Anyone?
分两个阶段完成,首先排序然后分组。
要么是两个单独的工作表,或使用node-set()扩展,这样你就可以在一个样式表中进行两次传递(几乎每个xslt1引擎都有这个扩展名为
这个扩展名为mozilla'' s transformiix是值得注意的例外)
或使用xslt2草案实现,例如saxon8,其中node-set()不需要
。
>
David
do it in two stages, first sort then group.
Either as two separate sheets, or using a node-set() extension so you
can do two passes in a single stylesheet (almost every xslt1 engine has
this extension with mozilla''s transformiix being the notable exception)
or use xslt2 draft implementation such as saxon8 where node-set() isn''t
needed.
David
虽然我没有完全理解你想要的东西,在我看来
就像你可能想要使用一些变量一样。存储在一个变量var1
所有具有position()mod2 = 1的Photo元素,并且在另一个var2中所有
具有mod 2 = 0的照片元素。然后你可以对这两个
节点列表进行排序。
如果这没有用,试着给我一个更具体的例子(例如,
原始的xml,以及你希望如何看待
转换。
Although I do not understand completely what you want, it seems to me
like you might want to use some variables. Store in one variable var1
all Photo elements with position() mod2 =1, and in another var2 all
Photo elements with mod 2=0. Then you can sort both of these
node-lists.
If this did not help, try and give me a more concrete example (e.g.,
the original xml, and how you''d like it to look after the
transformation).
这篇关于XSL排序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!