The XMLXpath still shows up as standard TextLine widget and everything seems to be ignored.
Is there something missing for attaching this widget as default widget to the field?
Good shot. In the first version I was using IXMLPath instead (as seen in your widget code). This gives me this error:
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 858, in do_defineMacro
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 533, in do_optTag_tal
Module zope.tal.talinterpreter, line 518, in do_optTag
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 531, in do_optTag_tal
Module zope.tal.talinterpreter, line 513, in no_tag
Module zope.tal.talinterpreter, line 343, in interpret
Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
Module zope.tales.tales, line 696, in evaluate
Names:
{'args': (),
'context': <PloneSite at /d1>,
'default': <object object at 0x7ff57e2c3b80>,
'loop': {},
'nothing': None,
'options': {},
'repeat': {},
'request': <HTTPRequest, URL=http://dev1.veit-schiele.de:9080/d1/++add++xml_document>,
'template': <zope.browserpage.viewpagetemplatefile.ViewPageTemplateFile object at 0x8e23c10>,
'view': <plone.dexterity.browser.add.DefaultAddForm object at 0xb078dd0>,
'views': <zope.browserpage.viewpagetemplatefile.ViewMapper object at 0xb1b7ed0>}
Module zope.tales.expressions, line 217, in call
Module Products.PageTemplates.Expressions, line 147, in _eval
Module zope.tales.expressions, line 124, in _eval
Module Products.PageTemplates.Expressions, line 97, in trustedBoboAwareZopeTraverse
Module zope.traversing.adapters, line 126, in traversePathElement
traceback_info: (<XPathWidget 'form.widgets.metadata'>, '@@ploneform-render-widget')
Module zope.traversing.namespace, line 112, in namespaceLookup
Module Products.CMFPlone.patches.security, line 12, in traverse
Module zope.traversing.namespace, line 329, in traverse
LocationError: (<XPathWidget 'form.widgets.metadata'>, 'ploneform-render-widget')
So I switched to IField (as seen in other widget code).
So IXMLPath seems to be right but no idea where the LocationError is coming from and related to what.
I did not had time so far to dig through to z3c.form for finding what's going on here.
searching for the definition of ploneform-render-widget, it's a browser view registered in plone.app.z3cform for z3c.form.interfaces.IWidget contexts.
your IXPathWidget interface has to subclass the z3c.form.interfaces.IWidget ( .existdb/src/bf3d262ebd37994e0404d9ab2aa940621869e37d/zopyx/existdb/dx/widget.py?at=dexterity#cl-29 ). i guess, that does the trick (it's also the case for the recurrence widget).
note, that z3c.form.interfaces.IFieldWidget, which your XPathFieldWidget implements, does not derive from z3c.form.interfaces.IWidget.
don't ask what the difference between IWidget and IFieldWidget is, and why the latter does not derive from the other. I don't know. i can even barely belive, that i'm answering z3c.form questions