Subject: Re: [xsl] Find several different attribute values on many elements From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 8 Feb 2024 22:22:54 -0000 |
I'm trying to process a collection of documents and extract the distinct-values for several attributes. My first attempt was this which is very slow
B B B B <xsl:variable name="ditacollectionString" B B B B B B B select="concat($srcPath, '?select=*.dita')"/>
B B B B <xsl:variable name="xmlcollectionString" B B B B B B B select="concat($srcPath, '?select=*.xml')"/>
B B B B B B B <xsl:for-each select="distinct-values(collection($ditacollectionString)//*/@audience)" > B B B B B B B B B B B <xsl:value-of select="concat(., ' ')"/> B B B B B B B </xsl:for-each> B B B B B B B <xsl:for-each select="distinct-values(collection($ditacollectionString)//*/@platform)" > B B B B B B B B B B B <xsl:value-of select="concat(., ' ')"/> B B B B B B B </xsl:for-each> B B B B B B B <xsl:for-each select="distinct-values(collection($ditacollectionString)//*/@props)" > B B B B B B B B B B B <xsl:value-of select="concat(., ' ')"/> B B B B B B B </xsl:for-each>
I'm looking for a way to just make a single for-each loop and tried this
B B B B B B B B B B B <xsl:for-each select="distinct-values(collection($ditacollectionString)//element())" >
At this point you have created a sequence of (distinct) atomic values of the contents of all elements in the collection so you are basically dealing with strings (or other atomic values);
<xsl:apply-templates mode="conditions"/>
therefore doing an apply-templates without a select here, which then defaults to try to process the child nodes of the context item (which is not a node) doesn't work out.
B B B B B B B B B B B </xsl:for-each>
B B B B <xsl:template match="@product | @audience " mode="conditions"> B B B B B B B <xsl:value-of select="concat(., ' ')"/> B B B B </xsl:template>
But I get an error on the <xsl:apply-templates mode="conditions"/> indicating The required item type of the context item is node(), but the supplied expression {.} has item type xs:anyAtomicType.
I also need to do this with both .dita and .xml files and I'm planning on making 2 collections, is there a way to do one collection()?
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Find several different at, dvint dvint@xxxxxxxx | Thread | Re: [xsl] Find several different at, Piez, Wendell A. (Fe |
Re: [xsl] Find several different at, G. Ken Holman g.ken. | Date | Re: [xsl] Find several different at, Piez, Wendell A. (Fe |
Month |