Hi,
Since I dig grouping Martin’s 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(_dot_)honnen(_at_)gmx(_dot_)de
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>:
On 26.02.2021 07:22, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
<mailto:martin(_dot_)honnen(_at_)gmx(_dot_)de> wrote:
On 26.02.2021 06:13, Byomokesh Sahoo
sahoo(_dot_)byomokesh(_at_)gmail(_dot_)com 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--