Subject: Re: [xsl] Keeping result-document() from writing to a file more than once? From: "Eliot Kimber ekimber@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 6 May 2019 14:37:42 -0000 |
I didn't consider having multiple keys bound to the same resource, which of course can happen (and for good reasons). So ultimately you need a map of URIs to keys or simply a distinct-values() applied to the list of URIs provided by processing your key-to-resource map. Cheers, E. -- Eliot Kimber http://contrext.com o;?On 5/5/19, 10:36 PM, "Dan Vint dvint@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: I just wanted to post an update. Thanks for pointing me in this direction, it's the first time I've used maps. the idea works but we have a quirk in my DITA content. I've got different keys pointing to the same content. So although the map key is unique, when I go to write a file based upon the sourcename + target, I end up with the same filename for the output. The map solution gives me a convenient way to build an XML source that I can then process and check for duplicates in the filenames I'm creating. Thanks for the help ..dan At 08:39 AM 4/19/2019, Eliot Kimber ekimber@xxxxxxxxxxxx wrote: >Yes--thanks for catching that--cut and paste error. > >Cheers, > >E. > >-- >Eliot Kimber >http://contrext.com > > >C/B;B?On 4/19/19, 10:10 AM, "Martin Honnen >martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > On 19.04.2019 17:02, Eliot Kimber ekimber@xxxxxxxxxxxx wrote: > > > If you construct map entries for each use > and then combine them into a single map using > the "use-first" or "use-any" "duplicates" > option then you can blindly process all the > references and let the map-merge process > produce a single list of elements, e.g.; > > > > <xsl:variable name="use-entries" as="map(*)*"> > > <xsl:call-template name="find-all-conrefs"/> > > </xsl:variable> > > > > The find-all-conrefs template generates > maps, one for each id/element pair, which you > can create with xsl:map or using the literal > map constructor: "map{$key : $value}". > > > > Now make a single map: > > > > <xsl:variable name="use-map" as="map(*)" > > select="map:merge($use-entries, map{ 'duplicates' : 'use-any'}" > > /> > > > > And then process the entries to produce the result docs: > > > > <xsl:for-each select="map:keys($use-map)"> > > <xsl:variable name="key" select="." as="xs:string"/> > > <xsl:call-template name="make-result-doc"> > > <xsl:with-param name="key" as="xs:string" select="$key"/> > > <xsl:with-param name="key" > as="element() " select="map:get($use-map, $key)" as="element() "/> > > Isn't that second parameter supposed to be named > <xsl:with-param name="value" as="element() " > select="map:get($use-map, $key)" as="element() "/> > ? > > > </xsl:call-template> > > </xsl:for-each> > > > > > > ------------------------------------------------------------------------- -- Danny Vint Panoramic Photography http://www.dvint.com voice: 619-647-5780
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Keeping result-document(), Dan Vint dvint@xxxxx | Thread | [xsl] Using XSLT to process a direc, dvint@xxxxxxxxx |
Re: [xsl] Keeping result-document(), Dan Vint dvint@xxxxx | Date | [xsl] Using XSLT to process a direc, dvint@xxxxxxxxx |
Month |