I
IcedDante
Working with a sorted group, the inability to use following-sibling
(which uses Document Order) and convert an RTF (not avaible with the
Parser that we are using) hampered our ability to solve the following
problem. Consider the following set of Data:
<example>
<Credentials time="3">
<UserId>kiss</UserId>
</Credentials>
<Credentials time="1" break="true">
<UserId>bob</UserId>
</Credentials>
<Credentials time="6" break="true">
<UserId>my</UserId>
</Credentials>
<Credentials time="0">
<UserId>Look,</UserId>
</Credentials>
<Credentials time="2">
<UserId>can</UserId>
</Credentials>
<Credentials time="9">
<UserId>tookish</UserId>
</Credentials>
</example>
When sorted in ascending order, the data reads: "Look, bob can kiss my
tookish". For our requirements I am processing it as a descending set:
"tookish my kiss can bob Look,"
That is the first requirement. However, in the even that a node with
the property of "break" equal to "true" is found, processing should
halt (multiple nodes can have the break property, but we really only
care about the first one).
So the output should read: "tookish my"
I devised a solution by using the substring-before operator to select
the first break node's sorted position.
<xsl
aram name="breakPos">
<xsl:for-each select="example/Credentials">
<xsl:sort select="@time" order="descending" />
<xsl:call-template name="countSequence">
</xsl:call-template>
</xsl:for-each>
</xsl
aram>
<xsl
aram name="endElem">
<xsl:value-of select="substring-before($breakPos,'|')" />
</xsl
aram>
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="example/Credentials">
<xsl:sort select="@time" order="descending" />
<xsl:if test="($endElem = '') or (position() <= $endElem)">
<xsl:value-of select="UserId" /><br />
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
Yeah, this renders the html output:
tookish<br />
my<br />
but I felt like the "endElem" parameter derivation was kind of a hack.
Would there be a better solution- possibly using Meunchian grouping to
perform this fix?
(which uses Document Order) and convert an RTF (not avaible with the
Parser that we are using) hampered our ability to solve the following
problem. Consider the following set of Data:
<example>
<Credentials time="3">
<UserId>kiss</UserId>
</Credentials>
<Credentials time="1" break="true">
<UserId>bob</UserId>
</Credentials>
<Credentials time="6" break="true">
<UserId>my</UserId>
</Credentials>
<Credentials time="0">
<UserId>Look,</UserId>
</Credentials>
<Credentials time="2">
<UserId>can</UserId>
</Credentials>
<Credentials time="9">
<UserId>tookish</UserId>
</Credentials>
</example>
When sorted in ascending order, the data reads: "Look, bob can kiss my
tookish". For our requirements I am processing it as a descending set:
"tookish my kiss can bob Look,"
That is the first requirement. However, in the even that a node with
the property of "break" equal to "true" is found, processing should
halt (multiple nodes can have the break property, but we really only
care about the first one).
So the output should read: "tookish my"
I devised a solution by using the substring-before operator to select
the first break node's sorted position.
<xsl
<xsl:for-each select="example/Credentials">
<xsl:sort select="@time" order="descending" />
<xsl:call-template name="countSequence">
</xsl:call-template>
</xsl:for-each>
</xsl
<xsl
<xsl:value-of select="substring-before($breakPos,'|')" />
</xsl
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="example/Credentials">
<xsl:sort select="@time" order="descending" />
<xsl:if test="($endElem = '') or (position() <= $endElem)">
<xsl:value-of select="UserId" /><br />
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
Yeah, this renders the html output:
tookish<br />
my<br />
but I felt like the "endElem" parameter derivation was kind of a hack.
Would there be a better solution- possibly using Meunchian grouping to
perform this fix?