[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Trying to check if key is NOT found


Subject: Re: [xsl] Trying to check if key is NOT found
From: "Ihe Onwuka ihe.onwuka@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 13 Dec 2014 12:51:02 -0000

The sample code he posted shows he is using  XSLT 1.0.

On Sat, Dec 13, 2014 at 11:16 AM, David Rudel fwqhgads@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Russ,
> For whatever it is worth, I wouldn't use a key to do this type of
> thing, since you don't actually care about which node may have an
> @Target attribute matching the href in question.
>
> Assuming you have a processor that makes use of the map extension, you
> can simply find all valid @Target elements, set them as the domain for
> a map and then evaluate any given @href you want to see whether it is
> an entry in the map:
>
> First, you can create your map as so:
>
>       <xsl:variable name="target.map" as="map(xs:string,xs:integer)">
>          <xsl:map>
>             <xsl:for-each-group select="//element()[@Target]"
> group-by="string(@Target)">
>                <xsl:map-entry key="'#'||current-grouping-key()"
> select="1"/>
>             </xsl:for-each-group>
>          </xsl:map>
>       </xsl:variable>
>
> Then to determine whether a given href is valid or not, you just have
> to test whether $target.map(@href) equals 1.  If the href does not
> match any @Target element, then $target.map(@href) will be empty.
>
>
>
> On Fri, Dec 12, 2014 at 10:01 PM, russurquhart1@xxxxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> >
> >  Hi,
> >
> > I have a snippet of xsl to try and look through our document xml, and
> let me know if a given CrossRefence href attribute  does NOT contain an
> element with a matching Target attribute. The href attribute value is some
> string of characters, prefixed by a '#'.  There are several elements that
> can have a Target attribute so i wrote my xsl like the following:
> >
> >  .c9Y6TC { color:#0000ff; }.c49DIK { color:#ac306d; }.c18YC0 {
> color:#d00020; }.c5M9S0 { color:#000090; }.c69ORU { color:#aaaba0; }
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">


Current Thread
Keywords