Subject: Re: [xsl] XSLT for ditaval filtering From: "Wendell Piez wapiez@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 1 Feb 2022 21:35:10 -0000 |
Hey Chris, apologies, I think it was Rick who asked that! Cheers, Wendell On Tue, Feb 1, 2022 at 4:27 PM Wendell Piez wapiez@xxxxxxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > Hi Chris, > > Go with Eliot's solution if you want to do "real DITA". If you want to do > something on the cheap, you could factor our some of the logic > > <xsl:variable name="exclusions" select="$ditaval//prop[@att='product' and > @action='exclude']"/> > > <xsl:template match="*[@product=$exclusions/@val]"/> > > Or for an in-between capability, deploy a key, then match the node with a > template something like > > <xsl:template match="*[exists(key('exclusions',@product,$ditaval))]"/> > > Like Eliot's function, the key declaration can have fairly complex logic > if it needs to, for binding elements to inclusion or exclusion rules. > > Cheers, Wendell > > On Tue, Feb 1, 2022 at 3:36 PM Eliot Kimber eliot.kimber@xxxxxxxxxxxxxx < > xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > >> I would create an XSLT function that does the ditaval evaluation so that >> you can then use that bindly from match expressions, i.e.: >> >> >> >> <xsl:function name=blocal:isIncludedb as=bxs:Booleanb> >> <xsl:param name=bcontextb as=belement()b/> >> >> <xsl:param name=bditavalb as=bdocument-node()b/> >> >> >> >> <xsl:variable name=bresultb as=bxs:booleanb> >> >> <!bhard work goes here --> >> >> </xsl:variable> >> >> <xsl:sequence select=b$resultb/> >> >> </xsl:function> >> >> >> >> And then in your template you can do: >> >> >> >> <xsl:template match="*[not(local:isIncluded(., $ditaval))]"/> >> >> >> >> Or maybe the better name is isExcluded() so your check can be >> local:isExcluded() but you get the idea. >> >> >> >> From the DITAVAL file you can get the names of the attributes (or @props >> values) to check and then have generic code that evaluates them. >> >> >> >> When Ibve done this in the past I seem to recall normalizing all the >> @props specializations to the @props syntax and then evaluating that, but >> with XSLT 3 you could use XPath maps, which would be easier, i.e.: >> >> >> >> <xsl:variable name=bpropsValuesb as=bmap(*)b> >> >> <xsl:map-merge> >> >> <xsl:apply-templates select=b./@*b mode=bget-props-valuesb/> >> >> <xsl:map-merge> >> >> </xsl:variable> >> >> >> >> Where the keys are condition names and the values are a sequence of >> Booleans. You could then use map-left() to get the effective Boolean value >> for each condition and compare it to the include/exclude value. >> >> >> >> Or maybe Ibm making it too hard. >> >> >> >> Cheers, >> >> >> >> E. >> >> _____________________________________________ >> >> *Eliot Kimber* >> >> Sr Staff Content Engineer >> >> O: 512 554 9368 >> >> M: 512 554 9368 >> >> servicenow.com <https://www.servicenow.com> >> >> LinkedIn <https://www.linkedin.com/company/servicenow> | Twitter >> <https://twitter.com/servicenow> | YouTube >> <https://www.youtube.com/user/servicenowinc> | Facebook >> <https://www.facebook.com/servicenow> >> >> >> >> *From: *rick@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> >> *Date: *Tuesday, February 1, 2022 at 12:25 PM >> *To: *xsl-list@xxxxxxxxxxxxxxxxxxxxxx <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> >> *Subject: *Re: [xsl] XSLT for ditaval filtering >> >> *[External Email]* >> >> >> >> Here is my first attempt, which is doing the filtering. With this >> algorithm, I would need multiple rules for testing other possible ditaval >> attributes. >> >> >> >> <?xml version="1.0" encoding="UTF-8"?> >> >> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >> >> xmlns:xs="http://www.w3.org/2001/XMLSchema" >> >> xmlns:math="http://www.w3.org/2005/xpath-functions/math" >> >> exclude-result-prefixes="xs math" >> >> version="3.0" expand-text="yes"> >> >> >> >> <xsl:output indent="yes"/> >> >> >> >> <xsl:param name="ditaval-file" >> select="'file:///C:/DATA-10/content/Hide-Prod2.ditaval'"/> >> >> >> >> <xsl:variable name="ditaval" as="document-node()*"> >> >> <xsl:if test="doc-available($ditaval-file)=true()"> >> >> <xsl:sequence select="doc($ditaval-file)"/> >> >> </xsl:if> >> >> </xsl:variable> >> >> >> >> <xsl:template match="/map"> >> >> <map> >> >> <xsl:apply-templates select="@*"/> >> >> <xsl:apply-templates/> >> >> </map> >> >> </xsl:template> >> >> >> >> <xsl:template match="*[@product!=''][$ditaval//prop[@att='product' >> and @val=current()/@product and @action='exclude']]"/> >> >> <xsl:mode on-no-match="shallow-copy"/> >> >> >> >> </xsl:stylesheet> >> >> >> >> XSL-List info and archive >> <https://urldefense.com/v3/__http:/www.mulberrytech.com/xsl/xsl-list__;!!N4vo gdjhuJM!Sv6gz33vX2VZwdjnjFmgR1wfcLtcokfNrGU4X5oP6uzNiwqROmqKE7dnNqkzprhT-Hgjs Q$> >> >> EasyUnsubscribe >> <https://urldefense.com/v3/__http:/lists.mulberrytech.com/unsub/xsl-list/3453 418__;!!N4vogdjhuJM!Sv6gz33vX2VZwdjnjFmgR1wfcLtcokfNrGU4X5oP6uzNiwqROmqKE7dnN qkzprjWm91pfg$> >> (by email) >> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> >> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by >> email) >> > > > -- > ...Wendell Piez... ...wendell -at- nist -dot- gov... > ...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org... > ...github.com/wendellpiez... ...gitlab.coko.foundation/wendell... > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/174322> (by > email <>) > -- ...Wendell Piez... ...wendell -at- nist -dot- gov... ...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org... ...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSLT for ditaval filterin, Wendell Piez wapiez@ | Thread | Re: [xsl] XSLT for ditaval filterin, Chris Papademetrious |
Re: [xsl] XSLT for ditaval filterin, Wendell Piez wapiez@ | Date | [no subject], Unknown |
Month |