[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: problem reqarding link
Hi, An alternative is to look at it the other way by wiring it into your key: <xsl:key name="ids" match="p[@class = 'Bib_entry'] use="'#' || @id"/> Which approach is better depends on the case. Naming the key helps make sense of it: <xsl:key name="bib-entry-references" match="p[@class = 'Bib_entry'] use="'#' || @id"/> Cheers, Wendell From: Joga Singh Rawat jrawat@xxxxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Thursday, January 18, 2024 6:38 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: problem reqarding link Thanks an lot Michael!!! From: Michael Kay mike@xxxxxxxxxxxx<mailto:mike@xxxxxxxxxxxx> [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] Sent: 18 January 2024 14:31 To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: Re: problem reqarding link 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<mailto:jrawat@xxxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx<mailto:xsl-list-service@xxxxxxxxxxxx rytech.com>> 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>Text... <a href="#bibx" class="bibcit">1</a> xxx <a href="#biby" class="bibcit">2</a></p> <p class="Bib_entry" id='bibx">xxxxxxxxxxxx</p> <p class="Bib_entry" id='biby">xxxxxxxxxxxx</p> </html> output <html> <p>Text... <link rid="bibx" class="bibcit" sn="1">1</link> xxx <link rid="biby" class="bibcit" sn="2">2</a></p> <bib id='bibx" sn="1">xxxxxxxxxxxx</bib> <bib id='biby" sn="2">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="bibcit"> <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 ...JSR XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/293509> (by email) Click here<https://www.mailcontrol.com/sr/Iuw_9ItPYQvGX2PQPOmvUrvxg9nfQreSuSmdBA6I- sPP9pVVEl9RWlntwcE72iBW1wLVgp83_gmoZTw26POg4w==> to report this email as spam. XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/876847> (by email) XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/3302254> (by email<>)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|