Xml XLST中时间码的排序
有没有人想过我该怎么处理这件事?我想在xlst中按时间码值升序排序,但我认为典型的排序无法正确读取时间码值 我的最终目标是1)按时间码值升序对节点排序2)选择相应颜色的第一次迭代的时间码值,然后选择第二次,然后选择第三次,以此类推 如果我需要进一步澄清,请告诉我 以下是XML:Xml XLST中时间码的排序,xml,sorting,xslt,timecodes,Xml,Sorting,Xslt,Timecodes,有没有人想过我该怎么处理这件事?我想在xlst中按时间码值升序排序,但我认为典型的排序无法正确读取时间码值 我的最终目标是1)按时间码值升序对节点排序2)选择相应颜色的第一次迭代的时间码值,然后选择第二次,然后选择第三次,以此类推 如果我需要进一步澄清,请告诉我 以下是XML: <Metadata> <Locator> <Label>OUT</Label> <Color>Blue</Color> &l
<Metadata>
<Locator>
<Label>OUT</Label>
<Color>Blue</Color>
<Timecode>00;13;28;26</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>OUT</Label>
<Color>Magenta</Color>
<Timecode>00;15;29;26</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>IN</Label>
<Color>Magenta</Color>
<Timecode>00;23;48;19</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>IN</Label>
<Color>Magenta</Color>
<Timecode>00;03;15;13</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>OUT</Label>
<Color>Magenta</Color>
<Timecode>00;19;50;25</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>IN</Label>
<Color>Magenta</Color>
<Timecode>00;25;58;05</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>IN</Label>
<Color>Magenta</Color>
<Timecode>00;07;44;29</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>OUT</Label>
<Color>Magenta</Color>
<Timecode>00;09;05;28</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>IN</Label>
<Color>Blue</Color>
<Timecode>00;02;19;23</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>OUT</Label>
<Color>Magenta</Color>
<Timecode>00;13;16;11</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
<Locator>
<Label>OUT</Label>
<Color>Blue</Color>
<Timecode>00;02;31;23</Timecode>
<Username>bpayne</Username>
<Track>V1</Track>
</Locator>
出来
蓝色
00;13;28;26
巴因
V1
出来
洋红
00;15;29;26
巴因
V1
在里面
洋红
00;23;48;19
巴因
V1
在里面
洋红
00;03;15;13
巴因
V1
出来
洋红
00;19;50;25
巴因
V1
在里面
洋红
00;25;58;05
巴因
V1
在里面
洋红
00;07;44;29
巴因
V1
出来
洋红
00;09;05;28
巴因
V1
在里面
蓝色
00;02;19;23
巴因
V1
出来
洋红
00;13;16;11
巴因
V1
出来
蓝色
00;02;31;23
巴因
V1
这是我正在使用的XLST的一部分。我需要首先按时间码值对节点进行排序,然后使用以下XSLT进行转换:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<TimeCodes>
<G1_TC_1_IN>
<xsl:choose>
<xsl:when test="Metadata/Locator[Color = 'Magenta'][1]">
<xsl:value-of select="concat(
substring-before(Metadata/Locator[Color = 'Magenta'][1]/Timecode, ';'), ':',
substring-before(substring-after(Metadata/Locator[Color = 'Magenta'][1]/Timecode, ';'), ';'), ':',
substring-after(substring-after(Metadata/Locator[Color = 'Magenta'][1]/Timecode, ';'), ';')
)"/>
</xsl:when>
<xsl:otherwise>18:00:00;00</xsl:otherwise>
</xsl:choose>
<xsl:text>@29.97</xsl:text>
</G1_TC_1_IN>
<G1_TC_1_OUT>
<xsl:choose>
<xsl:when test="Metadata/Locator[Color = 'Magenta'][2]">
<xsl:value-of select="concat(
substring-before(Metadata/Locator[Color = 'Magenta'][2]/Timecode, ';'), ':',
substring-before(substring-after(Metadata/Locator[Color = 'Magenta'][2]/Timecode, ';'), ';'), ':',
substring-after(substring-after(Metadata/Locator[Color = 'Magenta'][2]/Timecode, ';'), ';')
)"/>
</xsl:when>
<xsl:otherwise>18:00:00;00</xsl:otherwise>
</xsl:choose>
<xsl:text>@29.97</xsl:text>
</G1_TC_1_OUT>
........
<G2_TC_1_IN>
<xsl:choose>
<xsl:when test="Metadata/Locator[Color = 'Blue'][1]">
<xsl:value-of select="concat(
substring-before(Metadata/Locator[Color = 'Blue'][1]/Timecode, ';'), ':',
substring-before(substring-after(Metadata/Locator[Color = 'Blue'][1]/Timecode, ';'), ';'), ':',
substring-after(substring-after(Metadata/Locator[Color = 'Blue'][1]/Timecode, ';'), ';')
)"/>
</xsl:when>
<xsl:otherwise>18:00:00;00</xsl:otherwise>
</xsl:choose>
<xsl:text>@29.97</xsl:text>
</G2_TC_1_IN>
18:00:00;00
@29.97
18:00:00;00
@29.97
........
18:00:00;00
@29.97
要进行排序,您可以将应用模板
与嵌套的排序
一起使用,例如
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:strip-space elements="*"/>
<xsl:output indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Metadata">
<xsl:copy>
<xsl:apply-templates select="Locator">
<xsl:sort select="Timecode"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:transform>
在线。只要所有用逗号分隔的数值都有两个数字,就像你的值一样(
00;02;31;23
)。你谈到排序,但我在你的代码中没有看到任何xsl:sort
。您可以发布要为发布的XML输入创建的结果吗?