* Returns the Lenya meta data element.
* @param doc The XML document.
* @return A DOM element.
*/
protected Element getMetaElement(org.w3c.dom.Document doc) throws DocumentException {
NamespaceHelper namespaceHelper =
new NamespaceHelper(PageEnvelope.NAMESPACE, PageEnvelope.DEFAULT_PREFIX, doc);
Element documentElement = doc.getDocumentElement();
Element metaElement = namespaceHelper.getFirstChild(documentElement, META);
if (metaElement == null) {
metaElement = namespaceHelper.createElement(META);
Element[] children = DocumentHelper.getChildren(documentElement);
if (children.length == 0) {
documentElement.appendChild(metaElement);
} else {
documentElement.insertBefore(metaElement, children[0]);