Subject: Re: [xsl] problem reqarding link From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 18 Jan 2024 09:01:03 -0000 |
The simplest approach would be to change <xsl:for-each select="key('ids', .)"> to <xsl:for-each select="key('ids', translate(., '#', ''))"> to strip out the '#' character. This would be applied to @id attributes as well as @href attributes, but if the @id attributes never contain a "#", that's fine. Michael Kay Saxonica > On 18 Jan 2024, at 08:02, Joga Singh Rawat jrawat@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi Team, > I am not able to get required OUTPUT of @sn <link> because of hash (#) problem. Please help in this regard. > > Input > <html> > <p>Textb& <a href=b#bibxb class=bbibcitb>1</a> xxx <a href=b#bibyb class=bbibcitb>2</a></p> > <p class=bBib_entryb id=bbibxb>xxxxxxxxxxxx</p> > <p class=bBib_entryb id=bbibyb>xxxxxxxxxxxx</p> > </html> > > output > <html> > <p>Textb& <link rid=bbibxb class=bbibcitb sn=b1b>1</link> xxx <link rid=bbibyb class=bbibcitb sn=b2b>2</a></p> > <bib id=bbibxb sn=b1b>xxxxxxxxxxxx</bib> > <bib id=bbibyb sn=b2b>xxxxxxxxxxxx</bib> > </html> > > Xsl > <xsl:key name="ids" match="p[@class = 'Bib_entry'] use="@id"/> > > <xsl:template match="p[@class='Bib_entry']/@id | @href"> > <xsl:for-each select="key('ids', .)"> > <xsl:if test="name(.)= 'p'"> > <xsl:text/> > <xsl:number format="1" count="p[@class = 'Bib_entry']" level="any" from="html"/> > </xsl:if> > </xsl:for-each> > </xsl:template> > > <xsl:template match="a"> > <xsl:variable name="rid" select="substring-after(@href, '#')"/> > <xsl:choose> > <xsl:when test="@class = 'bibcit'"> > <link class=bbibcitb> > <xsl:attribute name="rid"> > <xsl:value-of select="$rid"/> > </xsl:attribute> > <xsl:attribute name="sn"> > <xsl:apply-templates select="@href"/> > </xsl:attribute> > <xsl:apply-templates/> > </link> > </xsl:when> > </xsl:choose> > </xsl:template> > > <xsl:template match="p[@class='Bib_entry']"> > <bib> > <xsl:call-template name="id"/> > <xsl:attribute name="sn"> > <xsl:apply-templates select="@id"/> > </xsl:attribute> > <xsl:apply-templates/> > </bib> > </xsl:template> > > Thanks a lot in advance > b&JSR > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] problem reqarding link, Joga Singh Rawat jra | Thread | Re: [xsl] problem reqarding link, Joga Singh Rawat jra |
[xsl] problem reqarding link, Joga Singh Rawat jra | Date | Re: [xsl] problem reqarding link, Joga Singh Rawat jra |
Month |