QEbu: Project specifica1ons
} QEbu provides an editor for metadata
following the EBU Core Metadata Set.
} The user is able to produce new metadata
documents or edit existing ones.
} A simple graphic interface helps the user in
his work by providing:
◦ Instant validation on all input fields;
◦ Dictionaries for dictionary based attributes;
◦ In-place documentation for all metadata
elements.
2. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
3. EBU Core Metadata Set
Has been developed by the EBU Expert
Community on Metadata (ECM).
} Latest revised in october 2011 (version
1.3).
} It makes use of Simple Dublin Core
metadata elements as well as more
complex structures with deeper
expressivity and flexibility.
} The general aim is to define a minimum list
of attributes characterising a media
resource.
}
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
4. QEbu:
Project
specifica1ons
QEbu provides an editor for metadata
following the EBU Core Metadata Set.
} The user is able to produce new metadata
documents or edit existing ones.
} A simple graphic interface helps the user in
his work by providing:
}
◦ Instant validation on all input fields;
◦ Dictionaries for dictionary based attributes;
◦ In-place documentation for all metadata
elements.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
5. Why
a
GUI?
Editing XML by hand is a hard task,
especially with high complex structure
definition.
} Using a GUI, the user can focus on
metadata content, instead of worry about
the format in which metadata will be
stored.
}
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
6. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
7. From
XML
to
C++
“A class for each element”
} Yes, but with as much code reuse as
possible.
}
}
Exploiting objects composition and
inheritance, we tried to keep the number of
defined classes to a reasonable minimum.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
8. Managing
IDRefs
}
RightsType and PublicationType elements
contain a reference to a FormatType
◦ It’s a strong relation enforced by the usage of
ID-IDREF(s) types in the schema definition.
}
Corresponding classes have been designed
to contain a pointer to the format.
◦ Why not a simple string with the ID?
}
However pointers require careful handling:
◦ What happens if a format is deleted?
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
9. Root
Format
Map
}
We have introduced a root format map in
the top-level metadata element:
◦ Key: format ID;
◦ Value: formatType pointer and a list of listeners.
}
A listener is an object which needs to know
if a format is deleted (i.e. rightsType and
publicationType).
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
10. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
11. The
issue
}
}
Provide manipulation functionalities over
the contents of an XML file of interest, and
allow creation of a valid document from
scratch.
It is required a way to map model objects
from, and to, XML documents, in a sensible
and coherent way
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
12. Which
way?
The requirements of the application, and
the complexity of the schema, pretty much
call for DOM loud and clear.
} DOM makes for an easier management of
the contents, and cover all the
requirements needed.
}
}
What about performance?
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
13. Valida1on
}
A fundamental aspect of working with XML
is the validation of the contents…
◦ …but Qt doesn’t provide anything robust
enough.
}
In this case it is better to delegate to
something else, which does just that:
◦ xmllint, from libxml2
What if an input file does not validate?
} Validation comes for free when working
from scratch.
}
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
14. XML
to
memory…
}
}
}
This step is performed by EbuParser, which
visits recursively the document model
managing one node at a time.
“A class for each element, and for each
class its parser”.
We defined a pattern to achieve code
homogeneity and readability.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
15. EbuParser
snippet
T* EbuParser::parseT(const QDomElement &element)
{
// Sanity check for node element validity
if (element.isNull()) {
m_errorMsg = “T element is null";
return 0;
}
// Create custom object T
T *obj = new T;
// Get attribute(s).
t attributeName = element.attribute("attributeName");
// Sanity check for attribute validity, according to
// the
specific type
if (!attributeName.isValid())
obj->setAttributeName(attributeName);
// all
the
attributes parsed...
// Get element(s)
// A node list is expected in this example
QDomNodeList nodeList =
element.elementsByTagName("tagName");
for (int i=0; i < nodeList.size(); ++i) {
// In case of nested elements with a given name,
which
// are not dicrect children of the current node, skip
if (el.parentNode() != element)
continue;
// Recursively parse the child element, like we just
// did with its parent
ChildT *child = parseChildT(el);
// In case the returned child is not valid (i.e.
null)
if (!child) {
// Destroy the parent as well and return failure
delete obj;
return 0;
}
// In case of success append the child in the proper
// structure
obj->tagName().append(child);
}
// Proceed with more children elements…
return obj;
}
QDomElement el = nodeList.item(i).toElement();
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
16. …and
back!
}
}
The steps from memory to XML are
performed by EbuSerializer, which is the
dual counterpart of our custom parser just
described.
Once again, to iterate is human, to recurse
divine.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
17. EbuSerializer
snippet
QDomElement EbuSerializer::serializeT(T *obj)
{
// Create an empty unnamed element
QDomElement l = m_doc.createElement(" ");
e.appendChild(textNode);
l.appendChild(e);
// Serialize attribute(s), performing sanity check
// prior to write data
if (!obj->attribute1().isValid())
l.setAttribute("attribute1", obj->attribute1());
if (!obj->attribute2().isValid())
l.setAttribute("attribute2", obj->attribute2());
// ...all the attributes
if (!obj->element1().isEmpty())
// Create inner empty unnamed
}
if (obj->element2()) {
// This is a child element node
QDomElement e = serializeT2(obj->element2());
e.setTagName("anotherInnerElementName");
l.appendChild(e);
}
// For all the elements...
return l;
{
element
}
// This is just a text node
QDomElement e = m_doc.createElement(" ");
e.setTagName("innerElementName");
QDomText textNode =
m_doc.createTextNode(l->element1());
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
18. Infinite
descent
}
}
The EBU Core metadata allows the
definition of element types that may
include content of the very same type.
The recursive approach has proven to be
the only way worth implementing to handle
with ease the schema specifics.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
19. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
20. User
interface
}
}
For almost every object in the model, a
dedicated form has been created.
As a rule of thumb, the principle criteria
followed can be summarized like:
◦ Whenever possible attributes are managed via edit
fields;
◦ In case of range-restricted values, pickers are
employed;
◦ Children elements come with their own form, but few
exceptions (i.e. groups);
◦ If possible attributes/elements are grouped together
in a meaningful way;
◦ Recycle as much as possible exploiting composition.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
21. Stack
of
Forms
}
}
}
}
The user interface employs a custom pattern based on
stackable forms.
The users can see only one form at a time
No popup dialogs
Linear path of navigation
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
22. Lists,
lists
everywhere…
}
}
Many elements include subelements with
cardinality [0..*].
This poses some problems in the UI design:
◦ How to avoid congesting the interface?
◦ How to deal with the coexistence of lists and [0..1]
elements?
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
23. Users
first
aid
}
QEbu offers several features intended for
this goal:
◦ A quickstart tutorial;
◦ A navigation bar;
◦ Embedded documentation
◦ Auto completion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
24. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
25. Data
input
}
Design challenges:
◦ Provide user-friendly forms;
◦ Propose values from dictionaries;
◦ Grant an instantaneous input validation.
}
}
Qt framework already provides many
widgets for different type of input.
But something was still missing…
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
27. Auto-‐comple1on
Some fields are meant to store a reference
to standard lists of contents.
} The reference scheme are listed in EBU
Core documentation.
} Those values are retrieved from a set of
XML files downloaded from EBU website,
when available.
}
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
28. Schema-‐related
problems
EBU Core schema uses XML Schema types.
} It does not restrict them enough.
} What is the use of:
• duplicated timezones?
• years, months, days of duration?
• negative durations?
} It permits to express values which can be
meaningless or discordant.
} This may cause troubles for any program
which wants to handle those metadata.
}
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
29. Contents
Introduction
} Model design
} XML management
} GUI
}
◦ Interface
◦ Data management
}
Conclusion
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
30. Tes1ng
}
It is known that testing should be done by
someone not involved in the coding
phase…
◦ … but sometimes it is everything you got.
}
Being realistic, it is more a matter of where
bugs lie, rather than whether bugs are
there.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
31. Future
works
}
Internationalization (i18n)
◦ The code is already ready for i18n since all text
strings have been surrounded by Qt special
macros.
}
Forms re-design
◦ We treated each field and attribute equally.
◦ Feedback from EBU-EMC experts who actually
use such metadata could lead to better tailored
forms with relevant contents more easily
accessible.
}
Dynamic download of attribute dictionaries
from EBU website.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
32. QEbu
is
free
soware
}
}
QEbu is released under terms of the GNU
General Public License 3 as published by
the Free Software Foundation.
The application is built using Qt 4.8
framework by Nokia.
◦ http://qt.nokia.com/products/library
}
XML validation requires libxml2 to be
installed.
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor
33. QEbu
project
in
numbers
7 weeks
} 5 people
} 252 commits
} 39428 LOC
}
◦ 8438 in model/*
◦ 5485 in fileproc/*
◦ 25505 in ui/*
}
149 classes
◦ 68 in model/*
◦ 3 in fileproc/*
◦ 78 in ui/*
#FIATIFTADubai2013
Paolo Pasini: QEbu – an advanced metadata editor