Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2016, 01:02 PM
Authorized User
 
Join Date: Nov 2009
Posts: 10
Thanks: 1
Thanked 1 Time in 1 Post
Default merge multiple elements as a single element

Dear All,

I need suggestions to merge multiple elements as a single element. Provided sample input and output for your reference.

HTML Code:
Input:
<p>These pages are all about XSLT, an XML-based language <xref ref-type="bibr" rid="r1">1</xref><xref ref-type="bibr" rid="r2"/>--<xref ref-type="bibr" rid="r3">3</xref> for translating one set of XML into another set of XML, <xref ref-type="bibr" rid="r3">3</xref>, <xref ref-type="bibr" rid="r5">5</xref><xref ref-type="bibr" rid="r6"/>--<xref ref-type="bibr" rid="r7">7</xref> or into HTML. Of course, there are all sorts of other pages  <xref ref-type="bibr" rid="r1">7</xref>, <xref ref-type="bibr" rid="r3">8</xref>  around that cover XSLT. <xref ref-type="bibr" rid="r12">12</xref>, <xref ref-type="bibr" rid="r15">15</xref><xref ref-type="bibr" rid="r16"/><xref ref-type="bibr" rid="r17"/><xref ref-type="bibr" rid="r18"/><xref ref-type="bibr" rid="r19"/>--<xref ref-type="bibr" rid="r20">20</xref></p>

output:
<p>These pages are all about XSLT, an XML-based language <xref ref-type="bibr" rid="r1 r2 r3" post-process="true">1--3</xref> for translating one set of XML into another set of XML, <xref ref-type="bibr" rid="r3 r5 r6 r7">3, 5--7</xref> or into HTML. Of course, there are all sorts of other pages <xref ref-type="bibr" rid="r7 r8">7, 8</xref> around that cover XSLT. <xref ref-type="bibr" rid="r12 r15 r16 r17 r18 r19 r20">12, 15--20</xref></p>


The merge should happen only if characters (, )comma with space or ( ) space or (--) two hyphens or empty xref element (<xref ref-type="bibr" rid="r2"/>) appear inbetween xref elements.


E.g.
Input content: <xref ref-type="bibr" rid="r3">3</xref>, <xref ref-type="bibr" rid="r5">5</xref><xref ref-type="bibr" rid="r6"/>--<xref ref-type="bibr" rid="r7">7</xref>  

Expected ouput: <xref ref-type="bibr" rid="r1 r2 r3">1--3</xref>
Thanks and Regards
Bala

Last edited by priyan24; December 13th, 2016 at 08:55 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to know whether the father element has child elements or not JohnKiller XSLT 7 October 18th, 2012 09:50 AM
N Level elements in single table sophia ASP.NET 4 General Discussion 6 December 14th, 2011 10:12 AM
Checking an Element Against Multiple Elements ritagr XSLT 8 May 26th, 2011 07:18 PM
Optional element exists if has inner elements 2BOrNot2B XML 0 May 9th, 2008 02:11 PM
deleting or replacing a single element hasdy XSLT 3 March 14th, 2006 12:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.