Re: [xsl] Member function?

Subject: Re: [xsl] Member function?
From: "Dave Pawson dave.pawson@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Aug 2022 14:57:26 -0000
On Tue, 2 Aug 2022 at 15:54, Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> I would always use a map for this in XSLT 3.0, rather than a node tree; and then use map:contains() to check if a value is present.

<grin/> OK. Not something I've used Mike.
I had the index for a sort by date, hence thought to use it again.

I'll play with that, live and learn!

Thank you.



>
> Michael Kay
> Saxonica
>
> > On 2 Aug 2022, at 15:50, Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> >
> > Am 02.08.2022 um 16:10 schrieb Dave Pawson dave.pawson@xxxxxxxxx:
> >> xpath 2 or 3
> >>
> >> I have a sort index
> >> <d:sort_index name="my_sort">
> >>     <d:entry key="Jan" index="0"/>
> >>     <d:entry key="Feb" index="1"/>
> >>     <d:entry key="Mar" index="2"/>
> >>     <d:entry key="Apr" index="3"/>
> >>     <d:entry key="May" index="4"/>
> >>     <d:entry key="Jun" index="5"/>
> >>     <d:entry key="Jul" index="6"/>
> >>     <d:entry key="Aug" index="7"/>
> >>     <d:entry key="Sep" index="8"/>
> >>     <d:entry key="Oct" index="9"/>
> >>     <d:entry key="Nov" index="10"/>
> >>     <d:entry key="Dec" index="11"/>
> >>
> >>   </d:sort_index>
> >>
> >>   <xsl:variable name="sort_index" select="document('')//d:sort_index"/>
> >
> >
> > Given that you say XPath 2 or 3 I assume XSLT 2 or 3 so I would prefer a
> > variable or parameter e.g.
> >
> >
> > <xsl:variable name="sort-index">
> >
> >    <d:entry key="Jan" index="0"/>
> >    <d:entry key="Feb" index="1"/>
> >    <d:entry key="Mar" index="2"/>
> >    <d:entry key="Apr" index="3"/>
> >    <d:entry key="May" index="4"/>
> >    <d:entry key="Jun" index="5"/>
> >    <d:entry key="Jul" index="6"/>
> >    <d:entry key="Aug" index="7"/>
> >    <d:entry key="Sep" index="8"/>
> >    <d:entry key="Oct" index="9"/>
> >    <d:entry key="Nov" index="10"/>
> >    <d:entry key="Dec" index="11"/>
> >
> > </xsl:variable>
> >
> > and then a key
> >
> > <xsl:key name="sort-index" match="d:entry" use="@key"/>
> >
> >
> > and then a check on
> >
> >    key('sort-index', tokenize(d, ' '), $sort-index)
> >
> > or
> >
> >   key('sort-index', tokenize(d, '')[1], $sort-index)
> >
> >> and xml with many
> >>
> >> <book>
> >>       <author>
> >>         <f>H</f>
> >>         <s>Stone</s>
> >>       </author>
> >>       <t>Jane Doe</t>
> >>       <d>Jul 2018</d>
> >>     </book>
> >>
> >> I want to check that the d element (month) has an entry in the sort
> >> index using xsl:for-each over //book/d
> >>
> >> Suggestions please?
> >>
> >> TiA
> >>
> >>
> >
> >
> 
>


-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.

Current Thread