Subject: Re: [xsl] Apply Comment Position From: "Michael Müller-Hillebrand mmh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sat, 27 Feb 2021 19:09:56 -0000 |
Hi, Since I dig grouping Martinbs solution is clever and thanks for reminding me of tail()! Depending on the underlying logic, you might rather loop over the ext-link: <xsl:template match="article-meta"> <xsl:copy> <xsl:for-each select="ext-link"> <cp id="{@id}"> <email> <xsl:value-of select="."/> <!-- pull in first preceding comment --> <xsl:copy-of select="preceding-sibling::node()[self::comment()][1]"/> </email> </cp> </xsl:for-each> </xsl:copy> </xsl:template> Happy coding, - Michael > Am 26.02.2021 um 08:25 schrieb Martin Honnen martin.honnen@xxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>: > > > On 26.02.2021 07:22, Martin Honnen martin.honnen@xxxxxx <mailto:martin.honnen@xxxxxx> wrote: >> >> >> On 26.02.2021 06:13, Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx wrote: >>> Hi, >>> >>> Please look at the below xml, xslt and required output. I tried position function to get the comment inside <mail> in respective <ext-link>. I am facing a problem where ( <!--xmltex \gdef\EmailAuthIdDefnII{\MailAuthIdII}-->) refers to two <ext-link>. Could you please anyone help on this. >> >> >> Which version of XSLT can you use? What defines a relation between a comment "xmltext" and an "ext-link" element? Can't that just be solved by >> >> <xsl:template match="article-meta"> >> >> <xsl:copy> >> >> <xsl:for-each select="comment()[starts-with(., 'xmltext')] | ext-link" group-starting-with="comment()"> >> >> <xsl:for-each select="tail(current-group())"> >> >> <cp id="{@id}"> >> >> <email> >> >> <xsl:copy-of select="node(), current-group()[1]"/> >> >> </email> >> >> </cp> >> >> </xsl:for-each-group> >> >> </xsl:copy> >> >> </xsl:template> >> > > So that should have been > > > <xsl:template match="article-meta"> > <xsl:copy> > <xsl:for-each-group select="comment()[starts-with(., 'xmltex')] | ext-link" group-starting-with="comment()"> > <xsl:for-each select="tail(current-group())"> > <cp id="{@id}"> > <email> > <xsl:copy-of select="node(), current-group()[1]"/> > </email> > </cp> > </xsl:for-each> > </xsl:for-each-group> > </xsl:copy> > </xsl:template> > > > really, sorry, it seems without an editor I am not able to type well-formed and intended XSLT
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Apply Comment Position, Martin Honnen martin | Thread | |
Re: [xsl] Apply Comment Position, Martin Honnen martin | Date | |
Month |