[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Find several different attribute values on many e

Subject: Re: Find several different attribute values on many elements
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Feb 2024 23:51:40 -0000
Re:  Find several different attribute values on many  e
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()

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.