Subject: Re: [xsl] Find several different attribute values on many elements From: "dvint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 9 Feb 2024 01:46:12 -0000 |
The performance issue in the first came from running multiple for loops on the same content, getting down to one for loop has improved the performance.I agree, I don't understand why changing p to * makes a difference, but it does.I'll give your suggestion a try in the morning.Content is a bunch of dita topics of varying lengths and complexity - technical documentation.B I am trying to get a distinct list of all the values in those attributes across all the content and possible elements.Sent from my Verizon, Samsung Galaxy smartphone -------- Original message --------From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: 2/8/24 3:51 PM (GMT-08:00) To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Find several different attribute values on many elements 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 performanceproblems. Is the code above supposed to give better performance or for adifferent problem? I don't see why matching on * instead of p shouldfail, other than of course for any children of the first element thatyou 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 ofinput you have and what kind of result you want. It is not clear, atleast 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 knowattributes 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()
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Find several different at, Martin Honnen martin | Thread | Re: [xsl] Find several different at, Martin Honnen martin |
Re: [xsl] Find several different at, Martin Honnen martin | Date | Re: [xsl] Find several different at, Andre Cusson akhu01@ |
Month |