[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Apply Comment Position

Subject: Re: Apply Comment Position
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 26 Feb 2021 06:22:35 -0000
Re:  Apply Comment Position
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
> positionB function to get the comment inside <mail> in respective
> <ext-link>. I am facing a problem whereB  ( <!--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

 B  <xsl:template match="article-meta">

 B B B  <xsl:copy>

 B B B B B  <xsl:for-each select="comment()[starts-with(., 'xmltext')] |
ext-link" group-starting-with="comment()">

 B B B B B B B B  <xsl:for-each select="tail(current-group())">

 B B B B B B B B B B B  <cp id="{@id}">

 B B B B B B B B B B B B B  <email>

 B B B B B B B B B B B B B B B B  <xsl:copy-of select="node(),
current-group()[1]"/>

 B B B B B B B B B B B  </email>

 B B B B B B B B  </cp>

 B B B B  </xsl:for-each-group>

 B  </xsl:copy>

</xsl:template>

>
>
> 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
> <mailto: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
> <mailto:90727@xxxxxx></ext-link>
> <!--xmltex \gdef\EmailAuthIdDefnIV{\MailAuthIdIV}-->
> <ext-link ext-link-type="email" id="em5">sdu@xxxxxxx
> <mailto:sdu@xxxxxxx></ext-link>
> </article-meta>
> </article>
> REQUIRED OUTPUT: --
>
> <article>
> B  B <article-meta>
> B  B  B  <cp id="42em1">
> B  B  B  B  B <email>hadiao@nencn<!--xmltex
> \gdef\EmailAuthIdDefnI{\MailAuthIdI}--></email>
> B  B  B  </cp>
> B  B  B  <cp id="42em2">
> B  B  B  B  B <email>uip@xxxxxxxxx <mailto:uip@xxxxxxxxx><!--xmltex
> \gdef\EmailAuthIdDefnII{\MailAuthIdII}--></email>
> B  B  B  </cp>
> B  B  B  <cp id="42em3">
> B  B  B  B  B <email>gyuliu@hkbu<!--xmltex
> \gdef\EmailAuthIdDefnII{\MailAuthIdII}--></email>
> B  B  B  </cp>
> B  B  B  <cp id="em4">
> B  B  B  B  B <email>90727@xxxxxx <mailto:90727@xxxxxx><!--xmltex
> \gdef\EmailAuthIdDefnIV{\MailAuthIdIII}--></email>
> B  B  B  </cp>
> B  B  B  <cp id="em5">
> B  B  B  B  B <email>sdu@xxxxxxx <mailto:sdu@xxxxxxx><!--xmltex
> \gdef\EmailAuthIdDefnIV{\MailAuthIdIV}--></email>
> B  B  B  </cp>
> B  B </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
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/582271>
> (by email <>)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.