T
Tim
hi, I have some documents that need to be processed in one way if the
section titles belong to a certain set of titles and another way if a
section title is not in that set. I thought I had a pretty clever
solution but alas it doesn't work
I'm using xsltproc on freebsd.
This isn't working, but it is what I've tried.
(1) get a node set created from splitting a given string of the
canonical section titles and call that $need. (say the titles are
'Red', 'Green' and 'Blue', just for testing).
(2) get a node set of section titles from a document and call that
$have. the titles match for a test case, 'Red', 'Green', and 'Blue'.
(3) calculate the intersection of $have and $need. If the number of
nodes in $have is greater than the number of nodes in the
intersection, we have a title that is not in the first list ($need).
However, my intersection is empty. Maybe someone can help me figure
out how to solve this problem, using any method at all (intersecting
sets or not).
thanks,
--Tim Arnold
<xsl:template match="/">
<xsl:variable name="need">
<xsl:copy-of select="exsl:node-
set(str:split('Green,Blue,Red',','))" />
</xsl:variable>
<xsl:variable name="have">
<xsl:for-each select="chapter//section/info/title">
<xsl:element name="token">
<xsl:value-of select="." />
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:copy-of select="exsl:node-set(set:intersection($have,
$need))" />
</xsl:template>
</xsl:stylesheet>
section titles belong to a certain set of titles and another way if a
section title is not in that set. I thought I had a pretty clever
solution but alas it doesn't work
I'm using xsltproc on freebsd.
This isn't working, but it is what I've tried.
(1) get a node set created from splitting a given string of the
canonical section titles and call that $need. (say the titles are
'Red', 'Green' and 'Blue', just for testing).
(2) get a node set of section titles from a document and call that
$have. the titles match for a test case, 'Red', 'Green', and 'Blue'.
(3) calculate the intersection of $have and $need. If the number of
nodes in $have is greater than the number of nodes in the
intersection, we have a title that is not in the first list ($need).
However, my intersection is empty. Maybe someone can help me figure
out how to solve this problem, using any method at all (intersecting
sets or not).
thanks,
--Tim Arnold
<xsl:template match="/">
<xsl:variable name="need">
<xsl:copy-of select="exsl:node-
set(str:split('Green,Blue,Red',','))" />
</xsl:variable>
<xsl:variable name="have">
<xsl:for-each select="chapter//section/info/title">
<xsl:element name="token">
<xsl:value-of select="." />
</xsl:element>
</xsl:for-each>
</xsl:variable>
<xsl:copy-of select="exsl:node-set(set:intersection($have,
$need))" />
</xsl:template>
</xsl:stylesheet>