On 09/02/2024 00:32, dvint@xxxxxxxxx wrote:
Here is where I'm at now
<xsl:variable name="ditacollectionString"
B B B B select="concat($srcPath, '?select=(*.dita|*.xml)')"/>
<xsl:template match="/">
<xsl:variable name="CONDITIONS" >
B B B B <xsl:for-each
B B B B B B B select="collection($ditacollectionString)/*" >
B B B B B B B <xsl:apply-templates mode="conditions"/>
B B B B </xsl:for-each>
</xsl:variable>
<xsl:for-each select="distinct-values(tokenize($CONDITIONS, ' '))">
B B B B <xsl:sort/>
B B B B <xsl:if test="not(. ='')">
B B B B B B B <xsl:value-of select="$spaceTAB"/>
B B B B B B B <xsl:value-of select="$spaceTAB"/>
B B B B B B B <xsl:value-of select="."/><xsl:text>: true</xsl:text>
B B B B B B B <xsl:value-of select="$RETURN"/>
B B B B </xsl:if>
</xsl:for-each>
</xsl:template>
B B B B <xsl:template match="text()" mode="conditions"/>
B B B B <xsl:template match="p" mode="conditions">
B B B B B B B <xsl:if test="@product">
B B B B B B B B B B B <xsl:value-of select="concat(@product, ' ')"/>
B B B B B B B </xsl:if>
B B B B B B B <xsl:if test="@audience">
B B B B B B B B B B B <xsl:value-of select="concat(@audience, ' ')"/>
B B B B B B B </xsl:if>
B B B B B B B <xsl:if test="@platform">
B B B B B B B B B B B <xsl:value-of select="concat(@platform, ' ')"/>
B B B B B B B </xsl:if>
B B B B B B B <xsl:if test="@props">
B B B B B B B B B B B <xsl:value-of select="concat(@props, ' ')"/>
B B B B B B B </xsl:if>
B B B B B B B <xsl:if test="@otherprops">
B B B B B B B B B B B <xsl:value-of select="concat(@otherprops, ' ')"/>
B B B B B B B </xsl:if>
B B B B B B B <xsl:if test="@rev">
B B B B B B B B B B B <xsl:value-of select="concat(@rev, ' ')"/>
B B B B B B B </xsl:if>
B B B B </xsl:template>
This is working fine when I have the template match on "p". My problem
is these attributes can appear on all of the elements in the content
and more than one can appear on a given element.
So I tried substitution p with element() and with * and those fail to
produce anything.
Your initial post said you got the results you want but had performance
problems. Is the code above supposed to give better performance or for a
different problem? I don't see why matching on * instead of p should
fail, other than of course for any children of the first element that
you match on and process as you don't process any child nodes.
I think you might want to take a step back and tell us what kind of
input you have and what kind of result you want. It is not clear, at
least not now with different code samples that seem to do different things.
If you just want a flat list of distinct values of all those know
attributes why not do e.g.
B distinct-values(collection(...)!(.//@audience, .//@platform, .//@props))
If you want to sort them use
B distinct-values(collection(...)!(.//@audience, .//@platform,
.//@props)) => sort()
|