Subject: [xsl] Apply Comment Position From: "Byomokesh Sahoo sahoo.byomokesh@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 26 Feb 2021 05:13:38 -0000 |
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. INPUT -- <article> <article-meta> <!--xmltex \gdef\EmailAuthIdDefnI{\MailAuthIdI}--> <ext-link ext-link-type="email" id="42em1">hadiao@nencn</ext-link> <!--xmltex \gdef\EmailAuthIdDefnII{\MailAuthIdII}--> <ext-link ext-link-type="email" id="42em2">uip@xxxxxxxxx</ext-link> <!--xmltex \gdef\EmailAuthIdDefnII{\MailAuthIdII}--> <ext-link ext-link-type="email" id="42em3">gyuliu@hkbu</ext-link> <ext-link ext-link-type="email" id="em4">90727@xxxxxx</ext-link> <!--xmltex \gdef\EmailAuthIdDefnIV{\MailAuthIdIV}--> <ext-link ext-link-type="email" id="em5">sdu@xxxxxxx</ext-link> </article-meta> </article> REQUIRED OUTPUT: -- <article> <article-meta> <cp id="42em1"> <email>hadiao@nencn<!--xmltex \gdef\EmailAuthIdDefnI{\MailAuthIdI}--></email> </cp> <cp id="42em2"> <email>uip@xxxxxxxxx<!--xmltex \gdef\EmailAuthIdDefnII{\MailAuthIdII}--></email> </cp> <cp id="42em3"> <email>gyuliu@hkbu<!--xmltex \gdef\EmailAuthIdDefnII{\MailAuthIdII}--></email> </cp> <cp id="em4"> <email>90727@xxxxxx<!--xmltex \gdef\EmailAuthIdDefnIV{\MailAuthIdIII}--></email> </cp> <cp id="em5"> <email>sdu@xxxxxxx<!--xmltex \gdef\EmailAuthIdDefnIV{\MailAuthIdIV}--></email> </cp> </article-meta> </article> My XSLT: -- <xsl:template match="article"> <article> <xsl:apply-templates/> </article> </xsl:template> <xsl:template match="article-meta"> <xsl:element name="article-meta"> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="comment()"> <xsl:copy/> </xsl:template> <xsl:template match="ext-link[position()=1]"> <xsl:if test="@ext-link-type='email'[position()=1]"> <xsl:element name="cp"> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <email> <xsl:apply-templates/> <xsl:apply-templates select="ancestor-or-self::article-meta/comment()[matches(., 'EmailAuthIdDefn')][position()=1]"/> </email> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="ext-link[position()=2]"> <xsl:if test="@ext-link-type='email'[position()=1]"> <xsl:element name="cp"> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <email> <xsl:apply-templates/> <xsl:apply-templates select="ancestor-or-self::article-meta/comment()[matches(., 'EmailAuthIdDefn')][position()=2]"/> </email> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="ext-link[position()=3]"> <xsl:if test="@ext-link-type='email'[position()=1]"> <xsl:element name="cp"> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <email> <xsl:apply-templates/> <xsl:apply-templates select="ancestor-or-self::article-meta/comment()[matches(., 'EmailAuthIdDefn')][position()=3]"/> </email> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="ext-link[position()=4]"> <xsl:if test="@ext-link-type='email'[position()=1]"> <xsl:element name="cp"> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <email> <xsl:apply-templates/> <xsl:apply-templates select="ancestor-or-self::article-meta/comment()[matches(., 'EmailAuthIdDefn')][position()=4]"/> </email> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="ext-link[position()=5]"> <xsl:if test="@ext-link-type='email'[position()=1]"> <xsl:element name="cp"> <xsl:attribute name="id"> <xsl:value-of select="@id"/> </xsl:attribute> <email> <xsl:apply-templates/> <xsl:apply-templates select="ancestor-or-self::article-meta/comment()[matches(., 'EmailAuthIdDefn')][position()=5]"/> </email> </xsl:element> </xsl:if> </xsl:template> Thanks Byomokesh
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How can the mere switch f, Michael Kay mike@xxx | Thread | Re: [xsl] Apply Comment Position, Martin Honnen martin |
Re: [xsl] Outputting White Space On, Wendell Piez wapiez@ | Date | Re: [xsl] Apply Comment Position, Martin Honnen martin |
Month |