Subject: Re: [xsl] Moving element up hierarchy unless text nodes From: "Srinivas Gummula srinivasonmb@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 6 Apr 2015 19:38:28 -0000 |
Hi all, I have a requirement as below. i have one *source xml*, which as below. <Source> <Source1> *<Operation>XXXXXX</Operation>* <Source2> <Name>XXXX</Name> <Address>XXXX</Address> </Source2> <Source2> <Name>XXXX</Name> <Address>XXXX</Address> </Source2> </Source1> </Source>. I have* one Config XML*, which as below. <Source> <Source1> * <Operation>XXXXXX</Operation>* <Source3> <City>XXXX</City> <State>XXXX</State> </Source3> </Source1> </Source>. I want to merge the second xml with my source xml based on the Operation Name, my desired output xml should be. <Source> <Source1> *<Operation>XXXXXX</Operation>* <Source2> <Name>XXXX</Name> <Address>XXXX</Address> </Source2> <Source3> <City>XXXX</City> <State>XXXX</State> </Source3> </Source1> </Source>. like wise i have couple of config xml's, i need to merge them into source file based on Operation Using Nested For loop with IF Condition. I am new to XSLT, please help me to understand this. Thanks for advance. On Sat, Feb 28, 2015 at 5:21 AM, James Cummings james@xxxxxxxxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > Hi there. > > We've been looking at canonicalising use of <pb/> in a large collection of > TEI P5 XML texts. What we want to do is move this up the hierarchy unless > there is text before or after it only stopping when there is a sibling > element with textual content or when it hits the body/back/front elements. > i.e. someone might have encoded: > > > ====input==== > <body> > <div> > <lg> > <l><pb n="1"/> some text here</l> > <l>some text here <pb n="2"/></l> > </lg> > <lg> > <l>some text <pb n="3"/> some text</l> > <anchor xml:id="test"/> > <l><pb n="4"/>some text here</l> > <l>some text here <pb n="5"/></l> > <anchor xml:id="test2"/> > </lg> > </div> > <div> > <head>Some Text</head> > <lg> > <!-- A comment here --> > <l><pb n="6"/>Some text</l> > <l>Some text<pb n="7"/></l> > </lg> > </div> > </body> > ===== > > And what we'd want to end up with is: > > ===== > <body> > <pb n="1"/> > <div> > <lg> > <l> some text here</l> > <l>some text here </l> > </lg> > <pb n="2"/> > <lg> > <l>some text <pb n="3"/> some text</l> > <pb n="4"/> > <anchor xml:id="test"/> > <l>some text here</l> > <l>some text here </l> > <anchor xml:id="test2"/> > </lg> > </div> > <pb n="5"/> > <div> > <head>Some Text</head> > <pb n="6"/> > <lg> > <!-- A comment here --> > <l>Some text</l> > <l>Some text</l> > </lg> > </div> > <pb n="7"/> > </body> > ===== > > So as the <pb/> has text before/after it, it stays where it is. It should > move to the level in the hierarchy where its preceding-sibling::node()[1] > has text, passing over other empty elements or comments. (Of course, as > you might expect) the markup could be any element names, I just use > div/lg/l here because it is short and nicely hierarchicial as an example. > My approach so far has been, on every element to try to test if there is > text() between where I currently am and the following::pb[1] by selecting > everything between the start and the pb and looking at its normalised > string-length. But so far these tests aren't working right, and I haven't > even got my head round how to do it in reverse for <pb/> at the end. > > Has anyone done something like this before that I could look at? Any > suggestions? > > Thanks for any help! > > -James Cummings > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <-list/2598760> (by > email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Moving element up hierarc, Wendell Piez wapiez@ | Thread | [xsl] Merge based on shared element, Wendell Piez wapiez@ |
Re: [xsl] Moving element up hierarc, Wendell Piez wapiez@ | Date | [xsl] Merge based on shared element, Wendell Piez wapiez@ |
Month |