Collective.vdexvocabulary with Metadata

According to the specifications, Vdex XML files may include metadata. I understand this to mean that terms may contain attributes. Is my understanding correct? If so, does anyone have a sample vdex file with metadata or a project/module that uses it?

The c.vdexvocabulary module relies on imsvdex which has methods (getVocabMetadata and getTermMetadataById) for getting the metadata. These methods return lists of lxml.etree._Element types. However, I get 'None' using lxml find and xpath.

My vdex:

<?xml version="1.0" encoding="utf-8"?>
<vdex xmlns="" orderSignificant="false" language="en">

        <langstring language="en">English</langstring>
        <langstring language="it">Inglese</langstring>

My console code (vdex registered via c.vdexvocabulary vocabulary type):

>>>from zope.component import getUtility
>>>from zope.schema.interfaces import IVocabularyFactory
>>> factory = getUtility(IVocabularyFactory, 'collective.vdexvocabulary.languages')
>>>mdata = factory.vdex.getTermMetadataById('english')
[<Element {}metadata at 0x7f8b064e0a00>]
>>>element = mdata[0]
<type 'lxml.etree._Element'>
File "<console>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute ''text'

BTW, the vocabulary that I want to create is a standard geographic code. I want to add metadata like longitude and latitude, This is hardly updated so I figured it might be better if it is implemented as a vocabulary defined in a module.

Any leads would be highly appreciated.

Your XML document has an (implicitly) associated (XML) namespace ( Therefore, you cannot refer to elements with their local name. Try element.find('{}attribute1').text.


This is basic but I did not know.

The underlying imsvdex package supports fetching metadata from vocab, or term

but AFAIK the zope.schema.vocabulary and its terms nor the collective.vdexvocabulary and it's vdexterm does not support metadata.

So, this is something to be added. Pull Requests appreciated.

Plone Foundation Code of Conduct