From: Alfredo C. <alf...@gm...> - 2021-07-24 17:03:38
|
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 |
From: Jean-Paul R. <re...@gm...> - 2021-07-24 17:17:06
|
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 > |
From: <kev...@xp...> - 2021-07-24 19:04:06
|
There are multiple ways to skin a cat, one of these ways could be: Take the three fragments and make a single document under a wrapper, like: let $wrapper := <wrapper> {$var1} {$var2} {$var3} </wrapper> But you are making these fragments I guess so you could make that more generic or build the whole wrapper at one time. Then write an XSL containing the logic for your merge and apply the XSL. Kevin From: Jean-Paul Rehr <re...@gm...> Sent: Saturday, July 24, 2021 10:17 AM To: Alfredo Cosco <alf...@gm...> Cc: exist-open <exi...@li...> Subject: Re: [Exist-open] merging XML 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... <mailto: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... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open |
From: Alfredo C. <alf...@gm...> - 2021-07-25 09:55:16
|
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 >> > |
From: Слава С. <wet...@gm...> - 2021-07-25 11:31:51
|
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 > |
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 > |
From: Alfredo C. <alf...@gm...> - 2021-07-25 17:46:28
|
Hello Joe, Hi all, thanks for the code on github, I'm going to use it as a starting point but reading your message I realized that in few I'll have other problems to face. For example, if an element admits more than one attribute I'll have two identical code snapshots to merge with different attributes. I'll try to write rules from different cases, but after this thread I'm also thinking of rewriting all the logic of my script. What I'm trying to do is to create a TEI document starting from a web-form, the form may vary depending from the user configurations So: 1) I set the attribute "name" in the html input in this way: *fileDesc_titleStmt_title* or * fileDesc_sourceDesc_msDesc_physDesc_objectDesc *or (for attributes) *fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form* 2) Thanks to this forum I found a way (few weeks ago) to transform the *name* value in an XML snapshot: <fileDesc> <titleStmt> <title/> </titleStmt> </fileDesc> 3) Then I merge the snapshots and store an empty document in the database 4) Then I add the element and attribute values using the "UPDATE INSERT" In theory the approach works, but in practice seems to bring more troubles than solutions :\ What do you think? Alfredo Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski <jo...@gm...> ha scritto: > 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 >> > |
From: Joe W. <jo...@gm...> - 2021-07-26 13:28:15
|
Hi Alfredo, It sounds like you're trying to take the input of HTML forms and generate XML documents from the input. Have you investigated XForms, which can natively store XML models in the browser and submit XML instances to eXist? For XForms implementations, see XSLTForms [1] and Fore ("XFormish") [2]. To learn more about XForms, see Steven Pemberton's tutorial [3]. [1] https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip [2] https://github.com/Jinntec/Fore [3] https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/ Joe On Sun, Jul 25, 2021 at 1:46 PM Alfredo Cosco <alf...@gm...> wrote: > Hello Joe, Hi all, > thanks for the code on github, I'm going to use it as a starting point but > reading your message I realized that in few I'll have other problems to > face. > > For example, if an element admits more than one attribute I'll have two > identical code snapshots to merge with different attributes. > > I'll try to write rules from different cases, but after this thread I'm > also thinking of rewriting all the logic of my script. > > What I'm trying to do is to create a TEI document starting from a > web-form, the form may vary depending from the user configurations > > So: > 1) I set the attribute "name" in the html input in this way: > *fileDesc_titleStmt_title* or * > fileDesc_sourceDesc_msDesc_physDesc_objectDesc *or (for attributes) > *fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form* > > 2) Thanks to this forum I found a way (few weeks ago) to transform the > *name* value in an XML snapshot: > <fileDesc> > <titleStmt> > <title/> > </titleStmt> > </fileDesc> > > 3) Then I merge the snapshots and store an empty document in the database > > 4) Then I add the element and attribute values using the "UPDATE INSERT" > > In theory the approach works, but in practice seems to bring more troubles > than solutions :\ > > What do you think? > > Alfredo > > > > > > > > > Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski <jo...@gm...> > ha scritto: > >> 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 >>> >> |
From: Alfredo C. <alf...@gm...> - 2021-07-26 14:31:56
|
Hi Joe, yes I did, a couple of years ago, but I discarded the use of XForms because for the textareas they used an editor (it seems to me CKeditor) and to change it was necessary to completely recompile the application (and I have no idea how to do it) . Since I needed an XML editor I developed my own CODEMIRROR configuration dedicated to TEI-XML which guides my editors to write XML easily and, on the side, also has a "note taking environment" https://orazionelson.github.io/CodeMirrorXML4TEI/ https://orazionelson.github.io/CodeMirrorXML4TEI/editor.html Thanks for the suggestions, I will try to study the links you gave me. Alfredo Il giorno lun 26 lug 2021 alle ore 15:28 Joe Wicentowski <jo...@gm...> ha scritto: > Hi Alfredo, > > It sounds like you're trying to take the input of HTML forms and generate > XML documents from the input. Have you investigated XForms, which can > natively store XML models in the browser and submit XML instances to eXist? > For XForms implementations, see XSLTForms [1] and Fore ("XFormish") [2]. To > learn more about XForms, see Steven Pemberton's tutorial [3]. > > [1] > https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip > [2] https://github.com/Jinntec/Fore > [3] https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/ > > Joe > > > On Sun, Jul 25, 2021 at 1:46 PM Alfredo Cosco <alf...@gm...> > wrote: > >> Hello Joe, Hi all, >> thanks for the code on github, I'm going to use it as a starting point >> but reading your message I realized that in few I'll have other problems to >> face. >> >> For example, if an element admits more than one attribute I'll have two >> identical code snapshots to merge with different attributes. >> >> I'll try to write rules from different cases, but after this thread I'm >> also thinking of rewriting all the logic of my script. >> >> What I'm trying to do is to create a TEI document starting from a >> web-form, the form may vary depending from the user configurations >> >> So: >> 1) I set the attribute "name" in the html input in this way: >> *fileDesc_titleStmt_title* or * >> fileDesc_sourceDesc_msDesc_physDesc_objectDesc *or (for attributes) >> *fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form* >> >> 2) Thanks to this forum I found a way (few weeks ago) to transform the >> *name* value in an XML snapshot: >> <fileDesc> >> <titleStmt> >> <title/> >> </titleStmt> >> </fileDesc> >> >> 3) Then I merge the snapshots and store an empty document in the database >> >> 4) Then I add the element and attribute values using the "UPDATE INSERT" >> >> In theory the approach works, but in practice seems to bring more >> troubles than solutions :\ >> >> What do you think? >> >> Alfredo >> >> >> >> >> >> >> >> >> Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski < >> jo...@gm...> ha scritto: >> >>> 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 >>>> >>> |
From: <kev...@xp...> - 2021-07-26 19:20:14
|
We have a similar system for patient consent documents and several other hospital-related documents. We started with a combination for the authors, some customized Summernote (like CKEditor) and also Microsoft Word. The Word environment proved the best because we developed 2-way support for exist-db. Outbound we build a custom “document.xml”, using XSLT converting from their XML to Microsoft’s WORDML, stick it into a folder that has all the other .DOCX components, zip it up and send to download as a DOCX. All of this is in XQuery so they simply check out a document (or create a new default one) and after a second or two, a DOCX is downloaded to them. Author’s could work on what they wished and when finished upload the DOCX as a checkin. We use XQuery then to unzip, extract the “document.xml” and then basically reverse it through XSLT to make their XML and update the database. This method also worked great with their language translation vendors who run the DOCX through translation memory and upload the new French/Arabic/Welsh/Chinese/15+ other languages. Word Styles are used to understand structures (headings, lists, captions) but also impart logic. They have “chunks” of information that are finally rendered on demand to PDF through RenderX from exist-db (live at the hospital when needed) and the output content is customized with Choose/When or If structures that use Word styles to convey that. Like “If the logged in hospital is in the UK, show this paragraph, but if in Australia show this one …” Anyway, we found Word to be the best authoring environment for the authors primarily because XSLT can be used to strip out things not needed and while it is complex, it is all there. Even with HTML editors like CKEditor or Summernote, authors would write in Word and then copy/paste into the editor and the results (while they look ok, are rife with custom Word namespaces and HTML entities) that you have to program around and/or strip Javascript side before upload. With Word, we even extract the images (all SVG) and embed them into the Word document so they can see them and write content referencing it since modern Word supports SVG in Word documents now. Kevin From: Alfredo Cosco <alf...@gm...> Sent: Monday, July 26, 2021 7:31 AM To: Joe Wicentowski <jo...@gm...> Cc: exist-open <exi...@li...> Subject: Re: [Exist-open] merging XML Hi Joe, yes I did, a couple of years ago, but I discarded the use of XForms because for the textareas they used an editor (it seems to me CKeditor) and to change it was necessary to completely recompile the application (and I have no idea how to do it) . Since I needed an XML editor I developed my own CODEMIRROR configuration dedicated to TEI-XML which guides my editors to write XML easily and, on the side, also has a "note taking environment" https://orazionelson.github.io/CodeMirrorXML4TEI/ https://orazionelson.github.io/CodeMirrorXML4TEI/editor.html Thanks for the suggestions, I will try to study the links you gave me. Alfredo Il giorno lun 26 lug 2021 alle ore 15:28 Joe Wicentowski <jo...@gm... <mailto:jo...@gm...> > ha scritto: Hi Alfredo, It sounds like you're trying to take the input of HTML forms and generate XML documents from the input. Have you investigated XForms, which can natively store XML models in the browser and submit XML instances to eXist? For XForms implementations, see XSLTForms [1] and Fore ("XFormish") [2]. To learn more about XForms, see Steven Pemberton's tutorial [3]. [1] https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip [2] https://github.com/Jinntec/Fore [3] https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/ Joe On Sun, Jul 25, 2021 at 1:46 PM Alfredo Cosco <alf...@gm... <mailto:alf...@gm...> > wrote: Hello Joe, Hi all, thanks for the code on github, I'm going to use it as a starting point but reading your message I realized that in few I'll have other problems to face. For example, if an element admits more than one attribute I'll have two identical code snapshots to merge with different attributes. I'll try to write rules from different cases, but after this thread I'm also thinking of rewriting all the logic of my script. What I'm trying to do is to create a TEI document starting from a web-form, the form may vary depending from the user configurations So: 1) I set the attribute "name" in the html input in this way: fileDesc_titleStmt_title or fileDesc_sourceDesc_msDesc_physDesc_objectDesc or (for attributes) fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form 2) Thanks to this forum I found a way (few weeks ago) to transform the name value in an XML snapshot: <fileDesc> <titleStmt> <title/> </titleStmt> </fileDesc> 3) Then I merge the snapshots and store an empty document in the database 4) Then I add the element and attribute values using the "UPDATE INSERT" In theory the approach works, but in practice seems to bring more troubles than solutions :\ What do you think? Alfredo Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski <jo...@gm... <mailto:jo...@gm...> > ha scritto: 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... <mailto: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... <mailto: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... <mailto: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... <mailto: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... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open _______________________________________________ Exist-open mailing list Exi...@li... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open _______________________________________________ Exist-open mailing list Exi...@li... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open |
From: Christian W. <cwi...@gm...> - 2021-07-27 02:12:22
|
Hi Kevin, This sounds interesting. Is you code available somewhere? I'd like to study it, especially the XQuery part. All the best, Christian On 27/07/2021 04.19, kev...@xp... wrote: > > We have a similar system for patient consent documents and several > other hospital-related documents. > > We started with a combination for the authors, some customized > Summernote (like CKEditor) and also Microsoft Word. > > The Word environment proved the best because we developed 2-way > support for exist-db. > > Outbound we build a custom “document.xml”, using XSLT converting from > their XML to Microsoft’s WORDML, stick it into a folder that has all > the other .DOCX components, zip it up and send to download as a DOCX. > All of this is in XQuery so they simply check out a document (or > create a new default one) and after a second or two, a DOCX is > downloaded to them. > > Author’s could work on what they wished and when finished upload the > DOCX as a checkin. > > We use XQuery then to unzip, extract the “document.xml” and then > basically reverse it through XSLT to make their XML and update the > database. > > This method also worked great with their language translation vendors > who run the DOCX through translation memory and upload the new > French/Arabic/Welsh/Chinese/15+ other languages. > > Word Styles are used to understand structures (headings, lists, > captions) but also impart logic. They have “chunks” of information > that are finally rendered on demand to PDF through RenderX from > exist-db (live at the hospital when needed) and the output content is > customized with Choose/When or If structures that use Word styles to > convey that. Like “If the logged in hospital is in the UK, show this > paragraph, but if in Australia show this one …” > > Anyway, we found Word to be the best authoring environment for the > authors primarily because XSLT can be used to strip out things not > needed and while it is complex, it is all there. Even with HTML > editors like CKEditor or Summernote, authors would write in Word and > then copy/paste into the editor and the results (while they look ok, > are rife with custom Word namespaces and HTML entities) that you have > to program around and/or strip Javascript side before upload. With > Word, we even extract the images (all SVG) and embed them into the > Word document so they can see them and write content referencing it > since modern Word supports SVG in Word documents now. > > Kevin > > *From:* Alfredo Cosco <alf...@gm...> > *Sent:* Monday, July 26, 2021 7:31 AM > *To:* Joe Wicentowski <jo...@gm...> > *Cc:* exist-open <exi...@li...> > *Subject:* Re: [Exist-open] merging XML > > Hi Joe, > yes I did, a couple of years ago, but I discarded the use of XForms > because for the textareas they used an editor (it seems to me > CKeditor) and to change it was necessary to completely recompile the > application (and I have no idea how to do it) . > Since I needed an XML editor I developed my own CODEMIRROR > configuration dedicated to TEI-XML which guides my editors to write > XML easily and, on the side, also has a "note taking environment" > > https://orazionelson.github.io/CodeMirrorXML4TEI/ > <https://orazionelson.github.io/CodeMirrorXML4TEI/> > https://orazionelson.github.io/CodeMirrorXML4TEI/editor.html > <https://orazionelson.github.io/CodeMirrorXML4TEI/editor.html> > > Thanks for the suggestions, I will try to study the links you gave me. > > Alfredo > > Il giorno lun 26 lug 2021 alle ore 15:28 Joe Wicentowski > <jo...@gm... <mailto:jo...@gm...>> ha scritto: > > Hi Alfredo, > > It sounds like you're trying to take the input of HTML forms and > generate XML documents from the input. Have you investigated > XForms, which can natively store XML models in the browser and > submit XML instances to eXist? For XForms implementations, see > XSLTForms [1] and Fore ("XFormish") [2]. To learn more about > XForms, see Steven Pemberton's tutorial [3]. > > [1] > https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip > <https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip> > > [2] https://github.com/Jinntec/Fore <https://github.com/Jinntec/Fore> > > [3] https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/ > <https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/> > > Joe > > On Sun, Jul 25, 2021 at 1:46 PM Alfredo Cosco > <alf...@gm... <mailto:alf...@gm...>> wrote: > > Hello Joe, Hi all, > > thanks for the code on github, I'm going to use it as a > starting point but reading your message I realized that in few > I'll have other problems to face. > > For example, if an element admits more than one attribute I'll > have two identical code snapshots to merge with different > attributes. > > I'll try to write rules from different cases, but after this > thread I'm also thinking of rewriting all the logic of my script. > > What I'm trying to do is to create a TEI document starting > from a web-form, the form may vary depending from the user > configurations > > So: > > 1) I set the attribute "name" in the html input in this way: > *fileDesc_titleStmt_title* or > *fileDesc_sourceDesc_msDesc_physDesc_objectDesc *or (for > attributes) > > *fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form* > > 2) Thanks to this forum I found a way (few weeks ago) to > transform the *name* value in an XML snapshot: > > <fileDesc> > <titleStmt> > <title/> > </titleStmt> > </fileDesc> > > 3) Then I merge the snapshots and store an empty document in > the database > > 4) Then I add the element and attribute values using the > "UPDATE INSERT" > > In theory the approach works, but in practice seems to bring > more troubles than solutions :\ > > What do you think? > > Alfredo > > Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski > <jo...@gm... <mailto:jo...@gm...>> ha scritto: > > 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 > <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... <mailto: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... > <mailto: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... <mailto: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... > <mailto: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... > <mailto:Exi...@li...> > https://lists.sourceforge.net/lists/listinfo/exist-open > <https://lists.sourceforge.net/lists/listinfo/exist-open> > > _______________________________________________ > Exist-open mailing list > Exi...@li... > <mailto:Exi...@li...> > https://lists.sourceforge.net/lists/listinfo/exist-open > <https://lists.sourceforge.net/lists/listinfo/exist-open> > > _______________________________________________ > Exist-open mailing list > Exi...@li... > <mailto:Exi...@li...> > https://lists.sourceforge.net/lists/listinfo/exist-open > <https://lists.sourceforge.net/lists/listinfo/exist-open> > > > > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open |
From: <kev...@xp...> - 2021-07-27 18:51:15
|
Christian: It is a closed system done for a customer. However I have no issues in sharing parts of this. I will send you email offline and if I get a chance this week carve out something on GIT or send it direct to you. Kevin From: Christian Wittern <cwi...@gm...> Sent: Monday, July 26, 2021 7:12 PM To: exi...@li... Subject: Re: [Exist-open] merging XML Hi Kevin, This sounds interesting. Is you code available somewhere? I'd like to study it, especially the XQuery part. All the best, Christian On 27/07/2021 04.19, kev...@xp... <mailto:kev...@xp...> wrote: We have a similar system for patient consent documents and several other hospital-related documents. We started with a combination for the authors, some customized Summernote (like CKEditor) and also Microsoft Word. The Word environment proved the best because we developed 2-way support for exist-db. Outbound we build a custom “document.xml”, using XSLT converting from their XML to Microsoft’s WORDML, stick it into a folder that has all the other .DOCX components, zip it up and send to download as a DOCX. All of this is in XQuery so they simply check out a document (or create a new default one) and after a second or two, a DOCX is downloaded to them. Author’s could work on what they wished and when finished upload the DOCX as a checkin. We use XQuery then to unzip, extract the “document.xml” and then basically reverse it through XSLT to make their XML and update the database. This method also worked great with their language translation vendors who run the DOCX through translation memory and upload the new French/Arabic/Welsh/Chinese/15+ other languages. Word Styles are used to understand structures (headings, lists, captions) but also impart logic. They have “chunks” of information that are finally rendered on demand to PDF through RenderX from exist-db (live at the hospital when needed) and the output content is customized with Choose/When or If structures that use Word styles to convey that. Like “If the logged in hospital is in the UK, show this paragraph, but if in Australia show this one …” Anyway, we found Word to be the best authoring environment for the authors primarily because XSLT can be used to strip out things not needed and while it is complex, it is all there. Even with HTML editors like CKEditor or Summernote, authors would write in Word and then copy/paste into the editor and the results (while they look ok, are rife with custom Word namespaces and HTML entities) that you have to program around and/or strip Javascript side before upload. With Word, we even extract the images (all SVG) and embed them into the Word document so they can see them and write content referencing it since modern Word supports SVG in Word documents now. Kevin From: Alfredo Cosco <mailto:alf...@gm...> <alf...@gm...> Sent: Monday, July 26, 2021 7:31 AM To: Joe Wicentowski <mailto:jo...@gm...> <jo...@gm...> Cc: exist-open <mailto:exi...@li...> <exi...@li...> Subject: Re: [Exist-open] merging XML Hi Joe, yes I did, a couple of years ago, but I discarded the use of XForms because for the textareas they used an editor (it seems to me CKeditor) and to change it was necessary to completely recompile the application (and I have no idea how to do it) . Since I needed an XML editor I developed my own CODEMIRROR configuration dedicated to TEI-XML which guides my editors to write XML easily and, on the side, also has a "note taking environment" https://orazionelson.github.io/CodeMirrorXML4TEI/ https://orazionelson.github.io/CodeMirrorXML4TEI/editor.html Thanks for the suggestions, I will try to study the links you gave me. Alfredo Il giorno lun 26 lug 2021 alle ore 15:28 Joe Wicentowski < <mailto:jo...@gm...> jo...@gm...> ha scritto: Hi Alfredo, It sounds like you're trying to take the input of HTML forms and generate XML documents from the input. Have you investigated XForms, which can natively store XML models in the browser and submit XML instances to eXist? For XForms implementations, see XSLTForms [1] and Fore ("XFormish") [2]. To learn more about XForms, see Steven Pemberton's tutorial [3]. [1] https://github.com/AlainCouthures/declarative4all/raw/master/public/direct/xsltforms.zip [2] https://github.com/Jinntec/Fore [3] https://homepages.cwi.nl/~steven/xforms/xforms-hands-on/ Joe On Sun, Jul 25, 2021 at 1:46 PM Alfredo Cosco <alf...@gm... <mailto:alf...@gm...> > wrote: Hello Joe, Hi all, thanks for the code on github, I'm going to use it as a starting point but reading your message I realized that in few I'll have other problems to face. For example, if an element admits more than one attribute I'll have two identical code snapshots to merge with different attributes. I'll try to write rules from different cases, but after this thread I'm also thinking of rewriting all the logic of my script. What I'm trying to do is to create a TEI document starting from a web-form, the form may vary depending from the user configurations So: 1) I set the attribute "name" in the html input in this way: fileDesc_titleStmt_title or fileDesc_sourceDesc_msDesc_physDesc_objectDesc or (for attributes) fileDesc_sourceDesc_msDesc_physDesc_objectDesc_@form 2) Thanks to this forum I found a way (few weeks ago) to transform the name value in an XML snapshot: <fileDesc> <titleStmt> <title/> </titleStmt> </fileDesc> 3) Then I merge the snapshots and store an empty document in the database 4) Then I add the element and attribute values using the "UPDATE INSERT" In theory the approach works, but in practice seems to bring more troubles than solutions :\ What do you think? Alfredo Il giorno dom 25 lug 2021 alle ore 17:54 Joe Wicentowski <jo...@gm... <mailto:jo...@gm...> > ha scritto: 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... <mailto: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... <mailto: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... <mailto: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... <mailto: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... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open _______________________________________________ Exist-open mailing list Exi...@li... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open _______________________________________________ Exist-open mailing list Exi...@li... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open _______________________________________________ Exist-open mailing list Exi...@li... <mailto:Exi...@li...> https://lists.sourceforge.net/lists/listinfo/exist-open |