Bug 157848 - XML Form Document: Binding of field with ":" won't work - needed for electronic invoices
Summary: XML Form Document: Binding of field with ":" won't work - needed for electron...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.1.0.0.alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Form-Controls
  Show dependency treegraph
 
Reported: 2023-10-20 09:47 UTC by Robert Großkopf
Modified: 2023-10-25 18:31 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Open the document and try to write something in first and second control. (10.42 KB, application/vnd.oasis.opendocument.text)
2023-10-20 09:47 UTC, Robert Großkopf
Details
Example for exported xml-code with namspaces (8.02 KB, text/xml)
2023-10-23 16:15 UTC, Robert Großkopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2023-10-20 09:47:24 UTC
Created attachment 190327 [details]
Open the document and try to write something in first and second control.

Download the attached XML form document.
Write some text in the first and in the second form control.
No problem with the second control but the first won't accept the content. 
Tip-Help says: "This is an invalid binding expression."

First field is named as "cbc:ID".
Second field is named as "Identifier". 

All other properties will be the same.
Binding will be created automatically, but every time I open the document or input data there will be added another element "cbc:ID" to the list of Instance 1.

Fields like this with ":" are evident for creating electronic invoices like XRechnung in Germany.
Comment 1 Alex Thurgood 2023-10-20 10:30:02 UTC
Confirming with 

Version: 7.6.2.1 (AARCH64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 8; OS: Mac OS X 14.0; UI render: Skia/Raster; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: fr-FR
Calc: threaded
Comment 2 BogdanB 2023-10-21 18:05:13 UTC
I can insert text in the first field, but it is deleted when I insert text in the second field.

Tested with
Version: 7.1.0.0.alpha0+
Build ID: 63bf8f042abe3c0f6989f6763d13f5389182b816
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Version: 7.2.8.0.0+ / LibreOffice Community
Build ID: ffa09959edd087794b1f2fe6b9b6faac484ef74b
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Version: 7.4.0.0.alpha1+ / LibreOffice Community
Build ID: 5a079652c1b1f968a851f47995b0a65b84d2d192
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 3a1cf7a24cfbf65adbbe692ac6f8c1b55c7807fe
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded

In debug version of 24.2 I get this:

warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:unotools/source/config/moduleoptions.cxx:475: unknown factory
warn:legacy.osl:169455:169455:forms/source/helper/windowstateguard.cxx:181: WindowStateGuard_Impl::disposing: where does this come from?
warn:legacy.osl:169455:169455:forms/source/helper/windowstateguard.cxx:181: WindowStateGuard_Impl::disposing: where does this come from?
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:unoxml:169455:169455:unoxml/source/xpath/xpathapi.cxx:264: libxml2 error: 
warn:legacy.osl:169455:169455:forms/source/xforms/binding.cxx:543: we should bind to the newly inserted node!
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding
warn:forms.component:169455:169455:forms/source/component/FormComponent.cxx:2579: DBG_UNHANDLED_EXCEPTION in transferControlValueToExternal exception: com.sun.star.form.binding.InvalidBindingStateException message: "no suitable node found at /home/tdf/lode/jenkins/workspace/lo_gerrit/tb/src_master/forms/source/xforms/binding.cxx:991" context: xforms::Binding

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 9a0018a356c89baf600a72eed8ee4ac927815b9b
CPU threads: 16; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 3 Julien Nabet 2023-10-22 12:00:11 UTC
I know nothing about xForms but when debugging, I got this part of bt when opening the form:
#0  XPath::structured_error_func(void*, _xmlError*) (error=0x5654ac1cd078) at unoxml/source/xpath/xpathapi.cxx:264
#1  0x00007f0b82d078ea in  () at /lib/x86_64-linux-gnu/libxml2.so.2
#2  0x00007f0b82d08de1 in  () at /lib/x86_64-linux-gnu/libxml2.so.2
#3  0x00007f0b82d08d35 in  () at /lib/x86_64-linux-gnu/libxml2.so.2
#4  0x00007f0b82d0b812 in xmlXPathEval () at /lib/x86_64-linux-gnu/libxml2.so.2
#5  0x00007f0b537ca5ca in XPath::CXPathAPI::eval(com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> const&, rtl::OUString const&)
    (this=0x7f0b3c033fb0, xContextNode=uno::Reference to (DOM::CElement *) 0x5654ab37ea08, expr="cbc:ID") at unoxml/source/xpath/xpathapi.cxx:333
#6  0x00007f0b537cb484 in non-virtual thunk to XPath::CXPathAPI::eval(com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode> const&, rtl::OUString const&) ()
    at /home/julien/lo/libreoffice/instdir/program/../program/libunoxmllo.so
#7  0x00007f0b437c3601 in xforms::ComputedExpression::_evaluate(xforms::EvaluationContext const&, rtl::OUString const&) (this=0x5654ab77c948, rContext=..., sExpression="cbc:ID")
    at forms/source/xforms/computedexpression.cxx:105
#8  0x00007f0b43810983 in xforms::PathExpression::evaluate(xforms::EvaluationContext const&) (this=0x5654ab77c948, rContext=...) at forms/source/xforms/pathexpression.cxx:81
#9  0x00007f0b4379ab35 in xforms::Binding::bind(bool) (this=0x5654ab77c780, bForceRebind=true) at forms/source/xforms/binding.cxx:532
#10 0x00007f0b4379b96c in xforms::Binding::bindingModified() (this=0x5654ab77c780) at forms/source/xforms/binding.cxx:708
#11 0x00007f0b4379b909 in xforms::Binding::update() (this=0x5654ab77c780) at forms/source/xforms/binding.cxx:185
#12 0x00007f0b437e5a27 in xforms::Model::rebind() (this=0x5654aae0fa60) at forms/source/xforms/model.cxx:227
#13 0x00007f0b437e698b in xforms::Model::initialize() (this=0x5654aae0fa60) at forms/source/xforms/model.cxx:393
#14 0x00007f0b437e69eb in xforms::Model::rebuild() (this=0x5654aae0fa60) at forms/source/xforms/model.cxx:399
#15 0x00007f0b437e8129 in xforms::Model::update() (this=0x5654aae0fa60) at forms/source/xforms/model.cxx:574
#16 0x00007f0b7e5bb34a in XFormsModelContext::endFastElement(int) (this=0x5654ac4b9c20) at xmloff/source/xforms/XFormsModelContext.cxx:104

(gdb) p *error
$4 = {domain = 12, code = 1219, message = 0x0, level = XML_ERR_ERROR, file = 0x0, line = 0, str1 = 0x5654aaf4f8f0 "cbc:ID", str2 = 0x0, str3 = 0x0, int1 = 6, int2 = 0, ctxt = 0x0, node = 0x0}

Searching error code 1219 in libxml, I got:
XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */
https://github.com/tenderlove/libxml2/blob/master/include/libxml/xmlerror.h

so "cbc" part is interpreted as a prefix and the prefix is unknown.
Comment 4 Robert Großkopf 2023-10-22 13:03:16 UTC
Hi Julien,

"so "cbc" part is interpreted as a prefix and the prefix is unknown."

It's right, it is a prefix. 
I have tried to edit namespaces: 
Edit Element → Add → Edit Namespaces
I added
ubl  urn:oasis:names:specification:ubl:schema:xsd:Invoice-2
cac  urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
cbc  urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2

This namespaces will be there after closing and reopening, but won't be there when saving the file and open it next times.

If I really could add this namespaces (which doesn't seem to work) might bee the problem is gone.
Comment 5 Julien Nabet 2023-10-22 20:57:42 UTC
I tried to add namespace it seems the save works since I can see:
<xforms:bind id="Bindung 1" nodeset="cbc:ID" required="true()" type="xsd:string" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
<xforms:bind id="Binding 1" nodeset="Identifier" required="true()" type="xsd:string" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" />
in fodt or when unzipping odt.

The pb is when opening the file, it doesn't seem to read it, at least it's indeed not in the namespace dialog.
Comment 6 Julien Nabet 2023-10-23 14:12:49 UTC
Testing again, namespaces dialog appears in 2 cases:
- when editing an instance
- when editing a binding
in both cases the title of dialog is "Namespaces for Forms".

BUT:
a) at first time
- when editing an instance
=> no namespace show
- when editing a binding
=> we got 2 namespaces:
-grddl http://www.w3.org/2003/g/data-view#
- rpt http://openoffice.org/2005/report

b) after having added namespace cbc (in instance or binding part!!), saved the file and reopen
- when editing an instance
=> still no namespace show
- when editing a binding
=> we got 3 namespaces:
- cbc urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2
- grddl http://www.w3.org/2003/g/data-view#
- rpt http://openoffice.org/2005/report

Anyway, "cbc:id" doesn't work after all this.

Also, when reading https://www.w3.org/community/xformsusers/wiki/XForms_2.0, it seems there are several locations where xmlns can be set, see https://www.w3.org/community/xformsusers/wiki/XForms_2.0#The_model_Element

I'm trying to compare the structure generated by LO and examples from W3C, it doesn't match.
In LO:
- forms
  - model
    - instance
      - custom ("invoice" here)
        - fields...
    - bind1
    - bind2

In XForms:
 - head
   - model
     - schema
     - instance
       - form
         - field
     - bind

what a mess...
Comment 7 Robert Großkopf 2023-10-23 16:15:22 UTC
Created attachment 190392 [details]
Example for exported xml-code with namspaces

Have added an example for the exported *.xml-file, which should also be exported by LibreOffice. I have exported this by using StarBasic Macros and a Writer file, will use it also by export from Base. 
For an allround solution it would be good to use XML-Forms, which should use this possibilities by default.
Comment 8 Julien Nabet 2023-10-25 18:31:17 UTC
After having added namespaces, I noticed this on console:
warn:legacy.osl:46743:46743:forms/source/xforms/binding.cxx:544: we should bind to the newly inserted node!

Trying to debugging but completely lost in libxml2.
can't help here=>uncc myself.