Package org.apache.lenya.xml

Examples of org.apache.lenya.xml.NamespaceHelper


        if (loading || !changed) {
            return;
        }
        try {
            Node repoNode = getRepositoryNode();
            NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", "site");

            int revision = getRevision(repoNode) + 1;
            helper.getDocument().getDocumentElement().setAttribute("revision",
                    Integer.toString(revision));

            saveNodes(getRoot(), helper, helper.getDocument().getDocumentElement());
            helper.save(repoNode.getOutputStream());
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new RepositoryException(e);
        }
View Full Code Here


            throws TransformerConfigurationException, TransformerException, IOException,
            ParserConfigurationException {

        assert (metaDataFile.getParentFile().exists());

        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc",
                "metadata");

        Element root = helper.getDocument().getDocumentElement();

        Iterator iter = dublinCoreParams.keySet().iterator();

        while (iter.hasNext()) {
            String tagName = (String) iter.next();
            String tagValue = (String) dublinCoreParams.get(tagName);
            root.appendChild(helper.createElement(tagName, tagValue));
        }

        DocumentHelper.writeDocument(helper.getDocument(), metaDataFile);
    }
View Full Code Here

        try {
            File file = getHistoryFile();
            file.getParentFile().mkdirs();
            file.createNewFile();

            NamespaceHelper helper = new NamespaceHelper(Workflow.NAMESPACE,
                    Workflow.DEFAULT_PREFIX, HISTORY_ELEMENT);

            Element historyElement = helper.getDocument().getDocumentElement();
            historyElement.setAttribute(WORKFLOW_ATTRIBUTE, workflowId);

            Element initialVersionElement = createInitialVersionElement(helper, situation,
                    workflowId);
            historyElement.appendChild(initialVersionElement);

            DocumentHelper.writeDocument(helper.getDocument(), file);
        } catch (Exception e) {
            throw new WorkflowException(e);
        }
    }
View Full Code Here

     * Returns the namespace helper for the history file.
     * @return A namespace helper.
     * @throws WorkflowException It the helper could not be obtained.
     */
    protected NamespaceHelper getNamespaceHelper() throws WorkflowException {
        NamespaceHelper helper;
        try {
            Document document = DocumentHelper.readDocument(getHistoryFile());
            helper = new NamespaceHelper(Workflow.NAMESPACE, Workflow.DEFAULT_PREFIX, document);
        } catch (Exception e) {
            throw new WorkflowException(e);
        }
        return helper;
    }
View Full Code Here

                        "The workflow history has not been initialized: The file ["
                                + getHistoryFile() + "] is missing.");
            }

            WorkflowInstanceImpl instance = createInstance();
            NamespaceHelper helper = getNamespaceHelper();

            String workflowId = getWorkflowId(helper);
            if (null == workflowId) {
                throw new WorkflowException("No workflow attribute set in history document!");
            }
View Full Code Here

            throws WorkflowException {
        try {
            org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(getHistoryFile());
            Element root = xmlDocument.getDocumentElement();

            NamespaceHelper helper = new NamespaceHelper(Workflow.NAMESPACE,
                    Workflow.DEFAULT_PREFIX, xmlDocument);

            Element versionElement = createVersionElement(helper, (StateImpl) instance
                    .getCurrentState(), situation, event);
View Full Code Here

     * @throws WorkflowException when something went wrong.
     */
    public Version[] getVersions() throws WorkflowException {
        List versions = new ArrayList();

        NamespaceHelper helper = getNamespaceHelper();
        Element documentElement = helper.getDocument().getDocumentElement();
        Element[] versionElements = getNamespaceHelper().getChildren(documentElement,
                VERSION_ELEMENT);

        for (int i = 0; i < versionElements.length; i++) {
            Version version = restoreVersion(helper, versionElements[i]);
View Full Code Here

            String[] prefixes = { DC_PREFIX, DCTERMS_PREFIX };
            String[][] arrays = { ELEMENTS, TERMS };
            Map[] maps = { elements, terms };

            for (int type = 0; type < 2; type++) {
                NamespaceHelper helper = new NamespaceHelper(namespaces[type], prefixes[type], doc);
                String[] elementNames = arrays[type];
                for (int i = 0; i < elementNames.length; i++) {
                    Element[] children = helper.getChildren(metaElement, elementNames[i]);
                    String[] values = new String[children.length];
                    for (int valueIndex = 0; valueIndex < children.length; valueIndex++) {
                        values[valueIndex] =
                            DocumentHelper.getSimpleElementText(children[valueIndex]);
                    }
View Full Code Here

        for (int i = 0; i < children.length; i++){
            metaElement.removeChild(children[i])
        }

        for (int type = 0; type < 2; type++) {
            NamespaceHelper helper = new NamespaceHelper(namespaces[type], prefixes[type], doc);
            String[] elementNames = arrays[type];
            for (int i = 0; i < elementNames.length; i++) {
                String[] values = (String[]) maps[type].get(elementNames[i]);
                for (int valueIndex = 0; valueIndex < values.length; valueIndex++) {
                    Element valueElement =
                        helper.createElement(elementNames[i], values[valueIndex]);
                    metaElement.appendChild(valueElement);
                }
            }
        }
View Full Code Here

     * 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]);
View Full Code Here

TOP

Related Classes of org.apache.lenya.xml.NamespaceHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.