package org.apache.cocoon.woody.datatype;

import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.cocoon.woody.datatype.SelectionList;
import org.apache.cocoon.woody.datatype.Datatype;
import org.apache.cocoon.woody.util.DomHelper;
import org.w3c.dom.Element;

public class FlowJXPathSelectionListWPromptBuilder implements SelectionListBuilder, Contextualizable {


    private Context context;

    public void contextualize(Context context) throws ContextException {
        this.context = context;
    }

    public SelectionList build(Element selectionListElement, Datatype datatype) throws Exception {

        String listPath = DomHelper.getAttribute(selectionListElement, "list-path");
        String keyPath = DomHelper.getAttribute(selectionListElement, "value-path");
        String valuePath = DomHelper.getAttribute(selectionListElement, "label-path");
        String msgKey = DomHelper.getAttribute(selectionListElement, "msg-key");

        return new FlowJXPathSelectionListWPrompt(context, listPath, keyPath, valuePath, msgKey, datatype);
    }

}

