[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Add id to next element
On Fri, May 20, 2022 at 01:34:41AM -0000, Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx scripsit: > Hi Graydon, Hello! > > What's wrong with > > > > <xsl:template match="section"> > > <xsl:copy> > > <xsl:apply-templates select="@*" mode="#current" /> > > <xsl:attribute name="id" > > select="(preceding-sibling::*[1][self::target]/@refid,generate-id(.)) => head()" /> > > <xsl:apply-templates mode="#current" /> > > </xsl:copy> > > </xsl:template> > > I normally use (expr1, expr2)[1] as an if-then-else for expressions evaluating to 0 or 1 node, I think it was Liam Quinn who pointed out that head() is smart about not picking up null strings while (expr1, expr2)[1] is not. I have found head() just plain More Useful as a pattern for "I want the first defined thing in this sequence". > but that arrow syntax is pretty neat. I should start using it. It's likely a deficiency in my noggin, but I find remembering the sequence parens is a lot easier when it reads as "make the sequence on the left the first parameter of the function on the right". (Something that can be vital with two maps and map:merge()!) The arrow operator is great for things like chained replaces, too; MUCH easier to read and edit replace() => replace() => replace() than replace(replace(replace())). -- Graydon Saunders | graydonish@xxxxxxxxx ^fs oferiode, pisses swa mfg. -- Deor ("That passed, so may this.")
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|