IcedDante wrote:
Quote:
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)
|
Mentioning what processor you're using would've been a good
idea, instead of mentioning just some of its limitations.
Quote:
hampered our ability to solve the following
problem. Consider the following set of Data:
|
[XML]
Quote:
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"
|
[partial solution reeking of imperative programming]
It would've been a better idea to post the entire
transformation instead of just parts of it.
Quote:
Yeah, this renders the html output:
tookish<br />
my<br />
|
Quote:
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?
|
I've grown accustomed to XSLT 2.0, so I can't think of any
elegant 1.0 solution off the top of my head. The following
works:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<result>
<xsl:apply-templates select="example/Credentials">
<xsl:sort select="@time" order="descending"/>
</xsl:apply-templates>
</result>
</xsl:template>
<xsl:template match="Credentials"/>
<xsl:template
match=
"
Credentials
[
not
(
../Credentials
[@time>current()/@time][@break='true']
)
]
">
<xsl:value-of select="UserId"/><br/>
</xsl:template>
</xsl:stylesheet>
....but specifying the sorting order in two separate places
in two different formats is a bit ugly, too, of course.
With XSLT 2.0, a much more elegant solution is possible:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()" mode="copy">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="sorted">
<xsl:apply-templates
select="example/Credentials" mode="copy">
<xsl:sort select="@time" order="descending"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:apply-templates select="$sorted/Credentials"/>
</xsl:template>
<xsl:template match="Credentials"/>
<xsl:template
match=
"
Credentials
[
not
(
preceding-sibling::Credentials[@break='true']
)
]
">
<xsl:value-of select="UserId"/><br/>
</xsl:template>
</xsl:stylesheet>
[Tested with Saxon-8B]
--
Pavel Lepin