Hi,
I am building a dynamic edit form that populates data from an fr-service-response-instance. The source XML is TEI and a data field can sometimes look like this: <bibl><emph>Beyträge zur Naturgeschichte</emph>. Erster Theil (1790; Bibliographie Nr. 00111).<ptr target="ref_d1e50334_00511"/></bibl> I would like to be able to "deep copy" the child nodes and the text of the <bibl> element into the fr-form-instance, and then get these values and put them into a textarea control for editing. For normal single nodes (those without child nodes), I have used xf:setvalue and it works great. I have tried xf:insert to do the copy of a complex field like this: <xf:action> <xf:var name="control-name" value="'note-type.Werke'" as="xs:string"/> <xf:var name="control-value" value="//tei:note[@type='Werke']/tei:bibl/tei:relatedItem/tei:bibl/node()" as="xs:element"/> <xf:insert context="instance('fr-form-instance')/*/*[name() = $control-name]" origin="$control-value"/> </xf:action> I am binding it like this: <xf:bind id="note-type.Werke-bind" ref="note-type.Werke/*" name="note-type.Werke"/> But, there are several problems. 1. node() only selects the value of the first child and not the text() of self. 2. If it is edited, the change is saved like this: <note-type.Werke> <emph xmlns="http://www.tei-c.org/ns/1.0">Beyträge zur Naturgeschicht</emph>. Erster Theil (1790; Bibliographie Nr. 00111).<ptr xmlns="http://www.tei-c.org/ns/1.0" target="ref_d1e50334_00511"/> <emph xmlns="http://www.tei-c.org/ns/1.0">Beyträge zur Naturgeschichte</emph>. Erster Theil (1790; Bibliographie Nr. 00111).<ptr xmlns="http://www.tei-c.org/ns/1.0" target="ref_d1e50334_00511"/> </note-type.Werke> 3. If I bind the ref with a wildcard like this, then the form only works for populated data and does not show the control for a new entry My questions are these: 1) What is the best way to transform/serialize, bind and display the child nodes (as XML elements) of a service response instance nodeset to a textarea control? 2) If a child node is entered in a new form text area control, it appears in the xml data escaped like this "<"emph">". Is it possible to do a literal copy and save of a node from the form control without escaping it? 2) Is it possible make xf:insert replace the first instance nodeset with the save data? Thank you kindly for your assistance, Christopher Johnson |
Administrator
|
Christopher,
> 1. What is the best way to transform/serialize, bind and display the child nodes (as XML elements) of a service response instance nodeset to a textarea control? What is the UI requirement? Would the user edit XML source in a text area? > 2) If a child node is entered in a new form text area control, it appears in the xml data escaped like this "<"emph">". Is it possible to do a literal copy and save of a node from the form control without escaping it? Do you use Form Runner? I see you refer to fr-form-instance which suggests a yes. In plain XForms, you can use saxon:serialize() and saxon:parse() to go back and forth, but all control data is stored as text within an element or an attribute. Currently all controls behave this way, and Form Runner assumes that format too. > 3) Is it possible make xf:insert replace the first instance nodeset with the save data? What is the first instance nodeset? -Erik |
Erik,
> What is the UI requirement? Would the user edit XML source in a text area? I think that I am looking for a micro-XML editor control, like a TinyMCE. The users will need to enter TEI-XML elements (as children) in the form text area that indicate references and formatting within the data field. > Do you use Form Runner? Yes. Is it possible to use saxon:transform to encode the form control text as XML in the output instance? My workflow takes the form entered data and transforms it back into TEI. I am using the eXist transform module with the Saxon transformer factory for post-processing. I have tried different XSLT serialization options to change the < and > back into < and > including character maps, but it seems not possible. Can they be reencoded (i.e. 'unescaped')? > What is the first instance nodeset? The first instance nodeset is the data from the response origin (TEI). The values that are set with xf:setvalue can be changed and are replaced on submission. The values that are set(?) with xf:insert are not replaced on submission. The submission duplicates the node in the output. Christopher |
Free forum by Nabble | Edit this page |