Hi Ralph, For the xf: and non-xf: elements, it depends how and where you declare the xforms namespace. With your form you declared the namespace with the prefix xf: on the html tag : xmlns:xf="http://www.w3.org/2002/xforms", so, as you noticed, you need to use this xf prefix with the xforms elements. Best, Josselin
Envoyé de mon iPhone > Le 11 févr. 2021 à 21:31, Ralph Corrigan <[email protected]> a écrit : > > > Thanks Josselin, clear explanations as ever! > I tried those changes but initially didn't get anywhere. Certainly the > context was wrong in the first <repeat>, but it turns out that - in my > instance at least - I needed to mark the <insert> as <xf:insert> - it then > worked just as expected, so (sorry, I didn't do the verbose although your > explanation was extremely helpful): > > <xf:trigger> > <xf:label>New role</xf:label> > <xf:insert > nodeset="instance('template')/listPerson/person/occupation" > at="index('repeat-occ')" > position="after" ev:event="DOMActivate" /> > </xf:trigger> > I'm a bit confused by this as the examples in the implementation file have a > mix of xf: and non-xf: and work fine, but my xml seems to need every element > marked 'xf:'. > > Anyway, many thanks - and hopefully I'll leave you in peace for a while now! > > Ralph > > > >> On 11/02/2021 18:52, Josselin Morvan wrote: >> >> Hi Ralph, >> >> As you specified a xf:group/@ref, everything inside this group starts from >> that point (you keep the context) >> >> You can try this - the node you want to repeat is your context node ('.' >> With Xpath ) : >> <xf:group id="pers" ref="instance('template')/listPerson/person"> >> <label>So this bit now works!</label> >> <xf:repeat id="repeat" nodeset="."> >> [...] >> </xf:repeat> >> [...] >> </xf:group> >> Or - you change your xf:group/@ref for the parent node listPerson, and you >> repeat the child node person : >> <xf:group id="pers" ref="instance('template')/listPerson"> >> <label>So this bit now works!</label> >> <xf:repeat id="repeat" nodeset="person"> >> >> [...] >> </xf:repeat> >> [...] >> </xf:group> >> Same idea for the repeat of occupation, as you already start from the node >> person, you just need to write : @nodeset='occupation' >> >> For the repeat, I think, at the beginning, you should be verbose to >> understand how it works : >> >> <insert context="." >> origin="instance('template')/listPerson/person/occupation" >> nodeset="occupation" >> at="index('repeat-occ')" >> position="after" >> ev:event="DOMActivate" /> >> To simplify, @context = your evaluation context (the node person in that >> case), @origin = the node you want to copy (you can take it from another >> instance), @nodeset = your target for the copy (here your will copy a new >> occupation node after (@position=after) the node occupation (@nodeset) with >> position()=index('repeat-occ') (@at='index('repeat-occ')') ) >> >> Let's try and keep us informed. >> >> Best, >> Josselin. >> >>> Le 11 févr. 2021 à 18:54, Ralph Corrigan <[email protected]> a écrit : >>> >>> Hi again >>> I wasn't wrong. >>> >>> I'm sure that this is going to be Xpath errors in the <trigger> but >>> <repeat> is not happening. I've stripped back the model (and added a couple >>> of other bits) and working round different Xpath permutations for the >>> groups/elements has given me some confidence in that. But the triggers, >>> while rendering fine, don't do anything. >>> >>> As always, any help gratefully appreciated >>> >>> Ralph >>> >>> >>> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> >>> <?xsltforms-options debug="yes"?> >>> <html xmlns="http://www.w3.org/1999/xhtml" >>> xmlns:xf="http://www.w3.org/2002/xforms" >>> xmlns:ev="http://www.w3.org/2001/xml-events" >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"> >>> >>> <head> >>> <title> New Person</title> >>> <xf:model> >>> >>> <xf:instance id="template"> >>> <items xmlns=""> >>> <listPerson> >>> <person xml:id="Unique name" sex="Sex"> >>> <persName><forename>Forename</forename><surname>Surname</surname></persName> >>> <occupation><rolename></rolename></occupation> >>> </person> >>> </listPerson> >>> </items> >>> </xf:instance> >>> <xf:submission id="s01" method="post" show="new" replace="all" >>> action="xsltforms/txs.php?exec=beautify.txs"> >>> <xf:message level="modeless" ev:event="xforms-submit-error">Submit >>> error.</xf:message> >>> </xf:submission> >>> </xf:model> >>> >>> </head> >>> <body> >>> <xf:group id="pers" ref="instance('template')/listPerson/person"> >>> <label>So this bit now works!</label> >>> <xf:repeat id="repeat" nodeset="instance('template')/listPerson/person"> >>> <xf:input ref="@xml:id"><xf:label>Unique name</xf:label></xf:input> >>> <xf:input ref="persName/forename"><xf:label>Forename</xf:label></xf:input> >>> <xf:input ref="persName/surname"><xf:label>Surname</xf:label></xf:input> >>> <xf:select1 ref="@sex" appearance="minimal"> >>> <xf:label>Sex</xf:label> >>> <xf:item> >>> <xf:label>Male</xf:label> >>> <xf:value>1</xf:value> >>> </xf:item> >>> <xf:item> >>> <xf:label>Female</xf:label> >>> <xf:value>2</xf:value> >>> </xf:item> >>> <xf:item> >>> <xf:label>Unknown</xf:label> >>> <xf:value>0</xf:value> >>> </xf:item> >>> </xf:select1> >>> >>> <xf:group id="occupation"> >>> <xf:repeat id="repeat-occ" >>> nodeset="instance('template')/listPerson/person/occupation"> >>> <xf:input ref="rolename"><xf:label>Role</xf:label></xf:input> >>> </xf:repeat> >>> <xf:trigger> >>> <xf:label>New role</xf:label> >>> <insert nodeset="instance('template')/listPerson/person/occupation" >>> at="index('repeat-occ')" >>> position="after" ev:event="DOMActivate" /> >>> </xf:trigger> >>> </xf:group> >>> >>> </xf:repeat> >>> <xf:trigger> >>> <xf:label>New</xf:label> >>> <insert nodeset="instance('template')/listPerson/person" >>> at="index('repeat')" >>> position="after" ev:event="DOMActivate" /> >>> </xf:trigger> >>> </xf:group> >>> >>> <xf:submit submission="s01"> >>> <xf:label>View</xf:label> >>> </xf:submit> >>> </body> >>> </html> >>> >>> >>> >>> >>> >>> >>> >>> On 10/02/2021 21:40, Ralph Corrigan wrote: >>> >>> Many thanks Josselin, I stupidly didn't realise that the whole Xpath was >>> required. >>> >>> That's rendering fine now, so on to the <repeat> sections. I fear I may be >>> in touch again, though... >>> >>> Thanks again >>> Ralph >>> >>> >>> >>> On 10/02/2021 20:09, Josselin Morvan wrote: >>> >>> Hi Ralph, >>> >>> I don't know if your are trying to work with the first instance (we cannot >>> access to the listPerson.xml file) or your #template instance, but I >>> suspect an error with your Xpath. >>> >>> If your listPerson is a XML-TEI file, your xml-tree should be something >>> like : >>> <TEI xmlns="http://www.tei-c.org/ns/1.0"> >>> <teiHeader/> >>> <text> >>> <body> >>> <listPerson> >>> <person> >>> <!-- person 1 --> >>> <persName> >>> <surname></surname> >>> <forename></forename> >>> </persName> >>> </person> >>> </listPerson> >>> </body> >>> </text> >>> </TEI> >>> Then if you want to target the surname and forename tags, your Xpath should >>> be something like /TEI/text/body/listPerson/person/persName/surname and >>> /TEI/text/body/listPerson/person/persName/forename. You can use >>> xf:group/@ref to shorten your link : >>> <xf:group ref="/TEI/text/body/listPerson/person/persName"> >>> <label>why does this not work?</label> >>> <xf:input ref="forename"><label>Forename</label></xf:input> >>> <xf:input ref="surname"><label>Surname></label></xf:input> >>> </xf:group> >>> >>> If your are trying to work with your #template instance, your Xpath is also >>> wrong and as it is not your first instance, you need to specify it in the >>> @ref : >>> >>> <xf:group >>> ref="instance('template')/TEI/text/body/listPerson/person/persName"> >>> <label>why does this not work?</label> >>> <xf:input ref="forename"><label>Forename</label></xf:input> >>> <xf:input ref="surname"><label>Surname></label></xf:input> >>> </xf:group> >>> >>> I think you'll also have to correct your xpath with your trigger to insert >>> a new person. >>> >>> Finally, if you plan to manage more than one person at a time, you should >>> take a look at the xf:repeat element. >>> (https://www.w3.org/TR/xforms11/#ui-repeat) >>> >>> If you declared a namespace (with listPerson.xml ?) it can also be the >>> origin of your issue as some browsers don't handle the namespace >>> declarations very well, but first let's try with corrected Xpath and keep >>> us informed! >>> >>> >>> Best, >>> Josselin. >>> >>> Le 10 févr. 2021 à 19:04, Ralph Corrigan <[email protected]> a écrit : >>> >>> Hi, >>> Apologies for this as I'm sure that I'm missing something extremely basic, >>> but I'm having problems with implementing Xsltforms running via an Apache >>> server on a Synology NAS (for now). I'm totally new to Xforms (in any >>> implementation) but have been working with TEI xml and fetchXML for a >>> couple of years, so I'm comfortable with that side of things. >>> >>> All of the test forms downloaded with the implementation work fine - they >>> have no problems at all. However, apparently simple changes cause the form >>> to either not render at all (without error message) or with key parts >>> missing. >>> >>> In the following example, I've changed some bits of Steve Pemberton's >>> 'todo.xml'. This form is a partial success in that the form does render, >>> and the s01 submission demonstrates that the src xml has been found and >>> read. However, the input fields (and I've deliberately kept this short >>> after the full model failed) do not appear (see image). There are no errors >>> in the trace log and the profiler recognises that the 2 input fields exist. >>> They just aren't being displayed. >>> >>> This problem is happening on all the examples I modify - I would understand >>> it (more) if the triggers failed as I'm new to this, but failing to even >>> render input/label seems really odd (and suggests that I'm making a very >>> basic error)! >>> >>> Any help gratefully received >>> >>> Ralph >>> >>> >>> <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?> >>> <?xsltforms-options debug="yes"?> >>> <html xmlns="http://www.w3.org/1999/xhtml" >>> xmlns:xf="http://www.w3.org/2002/xforms" >>> xmlns:ev="http://www.w3.org/2001/xml-events" >>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"> >>> <head> >>> <title> New Person</title> >>> <xf:model> >>> <xf:instance src="listPerson.xml"/> >>> <xf:instance id="template"> >>> <items xmlns=""> >>> <TEI><text><body><listPerson> >>> <person> >>> >>> <persName><forename>Forename</forename><surname>Surname</surname></persName> >>> <occupation><rolename></rolename></occupation> >>> </person> >>> </listPerson></body></text></TEI> >>> </items> >>> </xf:instance> >>> <xf:submission id="save" method="put" action="listperson.xml" >>> replace="none"/> >>> <xf:submission id="s01" method="post" show="new" replace="all" >>> action="xsltforms/txs.php?exec=beautify.txs"> >>> <xf:message level="modeless" ev:event="xforms-submit-error">Submit >>> error.</xf:message> >>> </xf:submission> >>> </xf:model> >>> >>> </head> >>> <body> >>> <xf:group> >>> <label>why does this not work?</label> >>> >>> <xf:input ref="forename"><label>Forename</label></xf:input> >>> <xf:input ref="surname"><label>Surname></label></xf:input> >>> >>> </xf:group> >>> <xf:trigger> >>> <xf:label>New</xf:label> >>> <xf:action ev:event="DOMActivate"> >>> <xf:insert context="/items" origin="instance('template')/person" >>> nodeset="persName" position="after" at="count(persName)"/> >>> </xf:action> >>> </xf:trigger> >>> <xf:submit submission="s01"> >>> <xf:label>View</xf:label> >>> </xf:submit> >>> </body> >>> </html> >>> <c709c5ba.png> >>> >>> _______________________________________________ >>> Xsltforms-support mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/xsltforms-support >>> >>> _______________________________________________ >>> Xsltforms-support mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/xsltforms-support
_______________________________________________ Xsltforms-support mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/xsltforms-support
