From: Joe W. <jo...@gm...> - 2021-07-25 15:54:55
|
Hi Alfredo, Slav asks good questions about the assumptions in your sample code. Assuming that duplicates should be merged rather than preserved, and testing only for element names (i.e., not examining attribute or text nodes), here's a basic query that will merge your fragments together into a structure approximating your target: https://gist.github.com/joewiz/b38279b8bd33de6949bb891370f76a04 Note that the order of fragments in the sequence you pass to the merge-fragments function is important. This is because when a new fragment is tested against the running composite document, if an element in the fragment doesn't match the element in the composite document, the fragment's element is deposited first before the rest of the composite document. This is why var3's titleStmt element appears first in the composite document, and var2's msIdentifier appears before var1's physDesc. Hopefully this gets you off to a good start and you're able to add any necessary checks besides element name to this to meet any other unstated assumptions / requirements. Joe On Sun, Jul 25, 2021 at 7:32 AM Слава Седов <wet...@gm...> wrote: > Hi, > > If your input and output set as testcase - it is 100% testcase or data may > vary? Do you need removing any duplicates if any or it is not possible in > your input? > > With best wishes, > Slav > > вс, 25 июл. 2021 г., 14:56 Alfredo Cosco <alf...@gm...>: > >> Hi Jean-Paul, >> I'm trying to merge the pieces on an "in memory" document then to store >> the result in a new document. >> But this logic can change if there is a better way. >> Thanks, >> Alfredo >> >> Il giorno sab 24 lug 2021 alle ore 19:16 Jean-Paul Rehr <re...@gm...> >> ha scritto: >> >>> Alfredo, are you creating a TEI document in memory, or are you trying to >>> insert these into an existing document stored in eXist-db? >>> >>> JPR >>> >>> On Sat, Jul 24, 2021 at 7:04 PM Alfredo Cosco <alf...@gm...> >>> wrote: >>> >>>> Hi all, >>>> I'm working on eXist 4.7 >>>> The problem is: >>>> >>>> I have tre variables with XML code: >>>> >>>> let $var1 := <fileDesc> >>>> <sourceDesc> >>>> <msDesc> >>>> <physDesc> >>>> <objectDesc form=""/> >>>> </physDesc> >>>> </msDesc> >>>> </sourceDesc> >>>> </fileDesc> >>>> >>>> >>>> let var2 := <fileDesc> >>>> <sourceDesc> >>>> <msDesc> >>>> <msIdentifier> >>>> <idno/> >>>> </msIdentifier> >>>> </msDesc> >>>> </sourceDesc> >>>> </fileDesc> >>>> >>>> let var3 := <fileDesc> >>>> <titleStmt> >>>> <title/> >>>> </titleStmt> >>>> </fileDesc> >>>> >>>> How can I merge there 3 snapshots and obtain something like: >>>> >>>> <fileDesc> >>>> <titleStmt> >>>> <title/> >>>> </titleStmt> >>>> <sourceDesc> >>>> <msDesc> >>>> <physDesc> >>>> <objectDesc form=""/> >>>> </physDesc> >>>> <msIdentifier> >>>> <idno/> >>>> </msIdentifier> >>>> </msDesc> >>>> </sourceDesc> >>>> </fileDesc> >>>> >>>> >>>> Thanks, >>>> Alfredo >>>> _______________________________________________ >>>> Exist-open mailing list >>>> Exi...@li... >>>> https://lists.sourceforge.net/lists/listinfo/exist-open >>>> >>> _______________________________________________ >> Exist-open mailing list >> Exi...@li... >> https://lists.sourceforge.net/lists/listinfo/exist-open >> > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > |