Example usage for org.dom4j Node selectSingleNode

List of usage examples for org.dom4j Node selectSingleNode

Introduction

In this page you can find the example usage for org.dom4j Node selectSingleNode.

Prototype

Node selectSingleNode(String xpathExpression);

Source Link

Document

selectSingleNode evaluates an XPath expression and returns the result as a single Node instance.

Usage

From source file:org.pentaho.platform.uifoundation.chart.XYSeriesCollectionChartComponent.java

License:Open Source License

@Override
public Dataset createChart(final Document doc) {
    if (actionPath != null) { // if we have a solution then get the values
        values = getActionData();//from w  ww .  j  a  v a2s  .  c o m
    }

    if (values == null) {
        // we could not get any data
        return null;
    }
    // get the chart node from the document
    Node chartAttributes = doc.selectSingleNode("//" + AbstractChartComponent.CHART_NODE_NAME); //$NON-NLS-1$
    // create the definition
    XYSeriesCollectionChartDefinition chartDefinition = new XYSeriesCollectionChartDefinition(
            (IPentahoResultSet) values, byRow, chartAttributes, getSession());

    // set the misc values from chartDefinition
    setChartType(chartDefinition.getChartType());
    setTitle(chartDefinition.getTitle());

    // get the URL template
    Node urlTemplateNode = chartAttributes.selectSingleNode(AbstractChartComponent.URLTEMPLATE_NODE_NAME);
    if (urlTemplateNode != null) {
        setUrlTemplate(urlTemplateNode.getText());
    }

    // get the additional parameter
    Node paramName2Node = chartAttributes.selectSingleNode(AbstractChartComponent.PARAM2_NODE_NAME);
    if (paramName2Node != null) {
        seriesName = paramName2Node.getText();
    }

    if ((chartDefinition.getWidth() != -1) && (width == -1)) {
        setWidth(chartDefinition.getWidth());
    }
    if ((chartDefinition.getHeight() != -1) && (height == -1)) {
        setHeight(chartDefinition.getHeight());
    }

    return chartDefinition;
}

From source file:org.pentaho.platform.uifoundation.chart.XYSeriesCollectionChartDefinition.java

License:Open Source License

private void setChartAttributes(final Node chartAttributes) {
    if (chartAttributes == null) {
        return;//w ww  .  j  av a 2 s . c o m
    }
    // get the chart type from the chart node -- this overrides the current
    // chart type
    setChartType(chartAttributes.selectSingleNode(ChartDefinition.TYPE_NODE_NAME));

    // set the chart background
    setChartBackground(chartAttributes.selectSingleNode(ChartDefinition.CHART_BACKGROUND_NODE_NAME));

    // set the plot background
    setPlotBackground(chartAttributes.selectSingleNode(ChartDefinition.PLOT_BACKGROUND_NODE_NAME));

    // set the orientation
    setOrientation(chartAttributes.selectSingleNode(XYChartDefinition.ORIENTATION_NODE_NAME));

    // do we want a legend
    setLegendIncluded(chartAttributes.selectSingleNode(ChartDefinition.INCLUDE_LEGEND_NODE_NAME));

    // get the chart title
    setTitle(chartAttributes.selectSingleNode(ChartDefinition.TITLE_NODE_NAME));
    Node backgroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME);
    Node foregroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME);

    if (backgroundAlphaNode != null) {
        setBackgroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME));
    }
    if (foregroundAlphaNode != null) {
        setForegroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME));
    }
    // get the chart subtitles

    // A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element (for XML schema
    // to
    // be well constructed and validate the XML .
    // We have deprecated <subtitle> as a child of the main node , and now require a <subtitles> parent node
    // under which <subtitle> can exist.

    List subtitles = chartAttributes.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);

    if ((subtitles == null) || (subtitles.isEmpty())) {
        Node subTitlesNode = chartAttributes.selectSingleNode(ChartDefinition.SUBTITLES_NODE_NAME);
        if (subTitlesNode != null) {
            subtitles = subTitlesNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
        }
    } else {
        // log a deprecation warning for this property...
        XYSeriesCollectionChartDefinition.getLogger()
                .warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", //$NON-NLS-1$
                        ChartDefinition.SUBTITLE_NODE_NAME, ChartDefinition.SUBTITLES_NODE_NAME));
        XYSeriesCollectionChartDefinition.getLogger().warn(Messages.getInstance()
                .getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", ChartDefinition.SUBTITLE_NODE_NAME)); //$NON-NLS-1$  
    }

    if (subtitles != null) {
        addSubTitles(subtitles);
    }

    // get the paint sequence
    setPaintSequence(chartAttributes.selectSingleNode(ChartDefinition.PALETTE_NODE_NAME));

    // get the stacked value
    setStacked(chartAttributes.selectSingleNode(ChartDefinition.STACKED_NODE_NAME));

    // get the 3D value
    setThreeD(chartAttributes.selectSingleNode(ChartDefinition.THREED_NODE_NAME));

    // set the width
    setWidth(chartAttributes.selectSingleNode(ChartDefinition.WIDTH_NODE_NAME));

    // set the height
    setHeight(chartAttributes.selectSingleNode(ChartDefinition.HEIGHT_NODE_NAME));

    // set the dot width
    setDotWidth(chartAttributes.selectSingleNode(ChartDefinition.DOT_WIDTH_NODE_NAME));

    // set the dot height
    setDotHeight(chartAttributes.selectSingleNode(ChartDefinition.DOT_HEIGHT_NODE_NAME));

    // set vertical tick labels flag
    setDomainVerticalTickLabels(
            chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));

    // set the border on or off
    setBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.CHART_BORDER_VISIBLE_NODE_NAME));

    // set the border Paint
    setBorderPaint(JFreeChartEngine
            .getPaint(chartAttributes.selectSingleNode(XYChartDefinition.CHART_BORDER_PAINT_NODE_NAME)));

    // set the title location
    setTitlePosition(chartAttributes.selectSingleNode(ChartDefinition.TITLE_POSITION_NODE_NAME));

    // set the title font
    setTitleFont(chartAttributes.selectSingleNode(ChartDefinition.TITLE_FONT_NODE_NAME));

    // set the domain title
    setDomainTitle(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_NODE_NAME));

    // set the domain title font
    setDomainTitleFont(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_FONT_NODE_NAME));

    // set the domain tick font
    setDomainTickFont(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TICK_FONT_NODE_NAME));

    // the the domain tick label number format
    setDomainTickFormat(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TICK_FORMAT_NODE_NAME));

    // set the range title
    setRangeTitle(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_NODE_NAME));

    // the the range title font
    setRangeTitleFont(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_FONT_NODE_NAME));

    // the the range tick font
    setRangeTickFont(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TICK_FONT_NODE_NAME));

    // the the range tick label number format
    setRangeTickFormat(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TICK_FORMAT_NODE_NAME));

    // set the domain minimum
    setDomainMinimum(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_MINIMUM_NODE_NAME));

    // set the domain minimum
    setDomainMaximum(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_MAXIMUM_NODE_NAME));

    // set the range minimum
    setRangeMinimum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MINIMUM_NODE_NAME));

    // set the range minimum
    setRangeMaximum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MAXIMUM_NODE_NAME));

    // set we want domain to include zero
    setDomainIncludesZero(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_INCLUDES_ZERO_NODE_NAME));

    // set we want domain to force zero
    setDomainStickyZero(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_STICKY_ZERO_NODE_NAME));

    // set we want domain to include zero
    setRangeIncludesZero(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_INCLUDES_ZERO_NODE_NAME));

    // set we want domain to force zero
    setRangeStickyZero(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_STICKY_ZERO_NODE_NAME));

    // set the line style
    setLineStyle(chartAttributes.selectSingleNode(ChartDefinition.LINE_STYLE_NODE_NAME));

    // set the line width
    setLineWidth(chartAttributes.selectSingleNode(ChartDefinition.LINE_WIDTH_NODE_NAME));

    // set the marker visibility
    setMarkersVisible(chartAttributes.selectSingleNode(ChartDefinition.MARKER_VISIBLE_NODE_NAME));

    // set legend font
    setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME));

    // set legend border visible
    setLegendBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME));

    setLegendPosition(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_POSITION_NODE_NAME));

    setTooltipContent(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_CONTENT_NODE_NAME));

    setTooltipYFormat(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_Y_FORMAT_NODE_NAME));

    setTooltipXFormat(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_X_FORMAT_NODE_NAME));

}

From source file:org.pentaho.platform.uifoundation.chart.XYZSeriesCollectionChartComponent.java

License:Open Source License

@Override
public Dataset createChart(final Document doc) {
    if (actionPath != null) { // if we have a solution then get the values
        values = getActionData();/*from  w ww  .  j a  v a2 s  .c om*/
    }

    if (values == null) {
        // we could not get any data
        return null;
    }
    // get the chart node from the document
    Node chartAttributes = doc.selectSingleNode("//" + AbstractChartComponent.CHART_NODE_NAME); //$NON-NLS-1$
    // create the definition
    XYZSeriesCollectionChartDefinition chartDefinition = new XYZSeriesCollectionChartDefinition(
            (IPentahoResultSet) values, byRow, chartAttributes, getSession());

    // set the misc values from chartDefinition
    setChartType(chartDefinition.getChartType());
    setTitle(chartDefinition.getTitle());

    // get the URL template
    Node urlTemplateNode = chartAttributes.selectSingleNode(AbstractChartComponent.URLTEMPLATE_NODE_NAME);
    if (urlTemplateNode != null) {
        setUrlTemplate(urlTemplateNode.getText());
    }

    // get the additional parameter
    Node paramName2Node = chartAttributes.selectSingleNode(AbstractChartComponent.PARAM2_NODE_NAME);
    if (paramName2Node != null) {
        seriesName = paramName2Node.getText();
    }

    if ((chartDefinition.getWidth() != -1) && (width == -1)) {
        setWidth(chartDefinition.getWidth());
    }
    if ((chartDefinition.getHeight() != -1) && (height == -1)) {
        setHeight(chartDefinition.getHeight());
    }

    return chartDefinition;
}

From source file:org.pentaho.platform.uifoundation.chart.XYZSeriesCollectionChartDefinition.java

License:Open Source License

private void setChartAttributes(final Node chartAttributes) {
    if (chartAttributes == null) {
        return;/*w w  w .  ja  v a2s  .c o  m*/
    }
    // get the chart type from the chart node -- this overrides the current
    // chart type
    setChartType(chartAttributes.selectSingleNode(ChartDefinition.TYPE_NODE_NAME));

    // set the chart background
    setChartBackground(chartAttributes.selectSingleNode(ChartDefinition.CHART_BACKGROUND_NODE_NAME));

    // set the plot background
    setPlotBackground(chartAttributes.selectSingleNode(ChartDefinition.PLOT_BACKGROUND_NODE_NAME));

    // set the orientation
    setOrientation(chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.ORIENTATION_NODE_NAME));

    // do we want a legend
    setLegendIncluded(chartAttributes.selectSingleNode(ChartDefinition.INCLUDE_LEGEND_NODE_NAME));

    setLegendPosition(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_POSITION_NODE_NAME));

    // get the chart title
    setTitle(chartAttributes.selectSingleNode(ChartDefinition.TITLE_NODE_NAME));

    Node backgroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME);
    Node foregroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME);

    if (backgroundAlphaNode != null) {
        setBackgroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME));
    }
    if (foregroundAlphaNode != null) {
        setForegroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME));
    }

    // get the chart subtitles

    // A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element (for XML schema
    // to
    // be well constructed and validate the XML .
    // We have deprecated <subtitle> as a child of the main node , and now require a <subtitles> parent node
    // under which <subtitle> can exist.

    List subtitles = chartAttributes.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);

    if ((subtitles == null) || (subtitles.isEmpty())) {
        Node subTitlesNode = chartAttributes.selectSingleNode(ChartDefinition.SUBTITLES_NODE_NAME);
        if (subTitlesNode != null) {
            subtitles = subTitlesNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
        }
    } else {
        // log a deprecation warning for this property...
        XYZSeriesCollectionChartDefinition.getLogger()
                .warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", //$NON-NLS-1$
                        ChartDefinition.SUBTITLE_NODE_NAME, ChartDefinition.SUBTITLES_NODE_NAME));
        XYZSeriesCollectionChartDefinition.getLogger().warn(Messages.getInstance()
                .getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", ChartDefinition.SUBTITLE_NODE_NAME)); //$NON-NLS-1$  
    }

    if (subtitles != null) {
        addSubTitles(subtitles);
    }

    // get the paint sequence
    setPaintSequence(chartAttributes.selectSingleNode(ChartDefinition.PALETTE_NODE_NAME));

    // get the stacked value
    setStacked(chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.STACKED_NODE_NAME));

    // get the 3D value
    setThreeD(chartAttributes.selectSingleNode(ChartDefinition.THREED_NODE_NAME));

    // set the width
    setWidth(chartAttributes.selectSingleNode(ChartDefinition.WIDTH_NODE_NAME));

    // set the height
    setHeight(chartAttributes.selectSingleNode(ChartDefinition.HEIGHT_NODE_NAME));

    // set the dot width
    setDotWidth(chartAttributes.selectSingleNode(ChartDefinition.DOT_WIDTH_NODE_NAME));

    // set the dot height
    setDotHeight(chartAttributes.selectSingleNode(ChartDefinition.DOT_HEIGHT_NODE_NAME));

    // set vertical tick labels flag
    setDomainVerticalTickLabels(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));

    // set the border on or off
    setBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.CHART_BORDER_VISIBLE_NODE_NAME));

    // set the border Paint
    setBorderPaint(JFreeChartEngine.getPaint(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.CHART_BORDER_PAINT_NODE_NAME)));

    // set the title location
    setTitlePosition(chartAttributes.selectSingleNode(ChartDefinition.TITLE_POSITION_NODE_NAME));

    // set the title font
    setTitleFont(chartAttributes.selectSingleNode(ChartDefinition.TITLE_FONT_NODE_NAME));

    // set the domain title
    setDomainTitle(chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_TITLE_NODE_NAME));

    // set the domain title font
    setDomainTitleFont(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_TITLE_FONT_NODE_NAME));

    // set the domain tick font
    setDomainTickFont(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_TICK_FONT_NODE_NAME));

    // the the domain tick label number format
    setDomainTickFormat(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_TICK_FORMAT_NODE_NAME));

    // set we want domain to include zero
    setRangeIncludesZero(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_INCLUDES_ZERO_NODE_NAME));

    // set the range title
    setRangeTitle(chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_TITLE_NODE_NAME));

    // the the range font
    setRangeTitleFont(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_TITLE_FONT_NODE_NAME));

    // the the range font
    setRangeTickFont(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_TICK_FONT_NODE_NAME));

    // the the range tick label number format
    setRangeTickFormat(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_TICK_FORMAT_NODE_NAME));

    // set the domain minimum
    setDomainMinimum(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_MINIMUM_NODE_NAME));

    // set the domain minimum
    setDomainMaximum(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_MAXIMUM_NODE_NAME));

    // set the range minimum
    setRangeMinimum(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_MINIMUM_NODE_NAME));

    // set the range minimum
    setRangeMaximum(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_MAXIMUM_NODE_NAME));

    // set we want domain to include zero
    setDomainIncludesZero(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_INCLUDES_ZERO_NODE_NAME));

    // set we want domain to force zero
    setDomainStickyZero(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.DOMAIN_STICKY_ZERO_NODE_NAME));

    // set we want domain to include zero
    setRangeIncludesZero(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_INCLUDES_ZERO_NODE_NAME));

    // set we want domain to force zero
    setRangeStickyZero(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.RANGE_STICKY_ZERO_NODE_NAME));

    // set the maximum bubble size
    setMaxBubbleSize(
            chartAttributes.selectSingleNode(XYZSeriesCollectionChartDefinition.MAX_BUBBLE_SIZE_NODE_NAME));

    // set the bubble label content
    setBubbleLabelContent(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.BUBBLE_LABEL_CONTENT_NODE_NAME));

    // set the bubble label's x value format
    setXFormat(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.BUBBLE_LABEL_X_FORMAT_NODE_NAME));

    // set the bubble label's y value format
    setYFormat(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.BUBBLE_LABEL_Y_FORMAT_NODE_NAME));

    // set the bubble label's z value format
    setZFormat(chartAttributes
            .selectSingleNode(XYZSeriesCollectionChartDefinition.BUBBLE_LABEL_Z_FORMAT_NODE_NAME));

    // set legend font
    setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME));

    // set legend border visible
    setLegendBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME));

}

From source file:org.pentaho.platform.uifoundation.component.xml.InputFormComponent.java

License:Open Source License

@Override
public Document getXmlContent() {

    ActionSequenceJCRHelper actionHelper = new ActionSequenceJCRHelper(getSession());
    IActionSequence actionSequence = actionHelper.getActionSequence(
            ActionInfo.buildSolutionPath(solution, path, actionName), getLoggingLevel(),
            RepositoryFilePermission.READ);

    if (actionSequence == null) {
        // TODO log this
        error(Messages.getInstance().getString("InputForm.ERROR_0004_ACTION_NOT_FOUND") + solution + path //$NON-NLS-1$
                + actionName);/* w w w .  j  a va 2  s  . c  o m*/
        return null;
    }

    List actions = actionSequence.getActionDefinitionsAndSequences();
    ISolutionActionDefinition action = (ISolutionActionDefinition) actions.get(0);

    Node node = action.getComponentSection();
    if (node == null) {
        error(Messages.getInstance().getString("InputForm.ERROR_0005_INBOX_DEFINITION_MISSING") + solution //$NON-NLS-1$
                + path + actionName);
        return null;
    }

    if (templateName == null) {

        // see if the template is specified in the action document
        Node templateNode = node.selectSingleNode("//template"); //$NON-NLS-1$
        if (templateNode != null) {
            templateName = templateNode.getText();
        }
        if (templateName == null) {
            error(Messages.getInstance().getString("InputForm.ERROR_0006_TEMPLATE_NOT_SPECIFIED")); //$NON-NLS-1$
            return null;
        }
    }
    Node xFormNode = node.selectSingleNode("//xForm"); //$NON-NLS-1$

    try {

        String actionTitle = actionSequence.getTitle();
        if (actionTitle != null) {
            setXslProperty("title", actionTitle); //$NON-NLS-1$
        }

        String description = actionSequence.getDescription();
        if (description != null) {
            setXslProperty("description", description); //$NON-NLS-1$
        }

        String xFormHtml = XForm.transformSnippet(xFormNode, getSession(), new SolutionURIResolver());
        if (xFormHtml == null) {
            error(Messages.getInstance().getString("InputForm.ERROR_0007_INBOX_DEFINITION_INVALID") + solution //$NON-NLS-1$
                    + path + actionName);
            return null;
        }
        Document document = DocumentHelper.parseText(xFormHtml);
        Node xFormHtmlNode = document.selectSingleNode("//xForm"); //$NON-NLS-1$

        setXslProperty("xForm", xFormHtmlNode.asXML()); //$NON-NLS-1$

        if ((stylesheetName != null) && !"".equals(stylesheetName)) { //$NON-NLS-1$
            setXslProperty("css", stylesheetName); //$NON-NLS-1$
        }
        setXsl("text/html", templateName); //$NON-NLS-1$

        return document;

    } catch (Exception e) {
        return null;
    }

}

From source file:org.pentaho.platform.util.xml.dom4j.XmlDom4JHelper.java

License:Open Source License

public static String getNodeText(final String xpath, final Node rootNode, final String defaultValue) {
    if (rootNode == null) {
        return (defaultValue);
    }/* ww  w . j  a  va2s  . c o  m*/
    Node node = rootNode.selectSingleNode(xpath);
    if (node == null) {
        return defaultValue;
    }
    return node.getText();
}

From source file:org.quickfixj.dictgenerator.Repository.java

License:Open Source License

private void initMsgTypes(Map<String, MsgType> msgTypeMap, String notReqXML) {
    System.out.println(getClass().getSimpleName() + ": Init MsgTypes (" + notReqXML + ")...");
    List<?> msgTypeNodes = msgType.selectNodes("//dataroot/MsgType[NotReqXML=" + notReqXML + "]");
    for (Object o : msgTypeNodes) {
        Node node = (Node) o;
        String msgID = node.selectSingleNode("MsgID").getText();
        String messageName = node.selectSingleNode("MessageName").getText();
        String componentType = node.selectSingleNode("ComponentType").getText();
        String category = node.selectSingleNode("Category").getText();
        String msgType = node.selectSingleNode("MsgType").getText();
        msgTypeMap.put(msgType, new MsgType(msgID, messageName, componentType, category, notReqXML, msgType));
    }/*from  w  ww  .j  a  va2s . com*/

    System.out.println(getClass().getSimpleName() + ": " + msgTypeMap.size() + " MsgTypes found");

    // Add msgContents
    for (MsgType msgType : msgTypeMap.values()) {
        List<?> msgContentsNodes = getMsgContents(msgType.getMsgID());
        System.out.println("\t " + msgType.getName());
        for (Object o : msgContentsNodes) {
            Node node = (Node) o;
            String tagText = node.selectSingleNode("TagText").getText();
            String reqd = node.selectSingleNode("Reqd").getText();
            //if (allFields.containsKey(tagText) && notReqXML.equals(allFields.get(tagText).getNotReqXML())) {
            if (allFields.containsKey(tagText)) {
                MsgTypeField msgTypeField = new MsgTypeField(allFields.get(tagText), reqd);
                msgType.addMsgContent(msgTypeField);
                System.out.println("\t\t " + allFields.get(tagText).getFieldName());
                //} else if (allComponents.containsKey(tagText) && notReqXML.equals(allComponents.get(tagText).getNotReqXML())) {
            } else if (allComponents.containsKey(tagText)) {
                MsgTypeComponent msgTypeComponent = new MsgTypeComponent(allComponents.get(tagText), reqd);
                msgType.addMsgContent(msgTypeComponent);
                System.out.println("\t\t " + allComponents.get(tagText).getName());
            } else {
                System.err.println("Could not find tagText: " + tagText);
            }
        }
    }
}

From source file:org.quickfixj.dictgenerator.Repository.java

License:Open Source License

private void initFields() {
    System.out.println(getClass().getSimpleName() + ": Init Fields...");
    List<?> fieldNodes = fields.selectNodes("//dataroot/Fields");
    for (Object o : fieldNodes) {
        Node node = (Node) o;
        String tag = node.selectSingleNode("Tag").getText();
        String fieldName = node.selectSingleNode("FieldName").getText();
        System.out.println("\t " + fieldName + "(" + tag + ")");
        String type = node.selectSingleNode("Type").getText();
        String desc = node.selectSingleNode("Desc").getText();
        String notReqXML = node.selectSingleNode("NotReqXML").getText();
        Field field = new Field(tag, fieldName, type, desc, notReqXML);
        allFields.put(field.getTag(), field);
        // Find enums
        List<?> enumNodes = enums.selectNodes("//dataroot/Enums[Tag=" + tag + "]");
        Collections.sort(enumNodes, new EnumNodeComparator());
        if (!enumNodes.isEmpty()) {
            for (Object enumO : enumNodes) {
                Node enumNode = (Node) enumO;
                String enumName = enumNode.selectSingleNode("Enum").getText();
                System.out.println("\t\t " + enumName);
                String enumDesc = enumNode.selectSingleNode("Description").getText();
                field.addEnum(new Enum(enumName, enumDesc));
            }//from w  w  w .  j  av a 2  s. c  o  m
        }
    }
    System.out.println(getClass().getSimpleName() + ": " + allFields.size() + " Fields found");
}

From source file:org.quickfixj.dictgenerator.Repository.java

License:Open Source License

private void initComponents() {
    System.out.println(getClass().getSimpleName() + ": Init Components...");
    List<?> componentNodes = components.selectNodes("//dataroot/Components");
    for (Object o : componentNodes) {
        Node node = (Node) o;
        String msgID = node.selectSingleNode("MsgID").getText();
        String componentName = node.selectSingleNode("ComponentName").getText();
        String componentType = node.selectSingleNode("ComponentType").getText();
        String category = node.selectSingleNode("Category").getText();
        String notReqXML = node.selectSingleNode("NotReqXML").getText();
        allComponents.put(componentName,
                new Component(msgID, componentName, componentType, category, notReqXML));
    }/*from  ww w  .jav  a  2  s  . c  o  m*/

    System.out.println(getClass().getSimpleName() + ": " + allComponents.size() + " Components found");

    // Add msgContents
    for (Component component : allComponents.values()) {
        addComponentMsgContent(component, "\t");
    }
}

From source file:org.quickfixj.dictgenerator.Repository.java

License:Open Source License

private void addComponentMsgContent(Component component, String prefix) {
    List<?> msgContentsNodes = getMsgContents(component.getMsgID());
    System.out.println(prefix + " " + component.getName());
    if (!component.getMsgContent().isEmpty()) {
        System.out.println(prefix + "\talready handled, return");
        return;/*from   w w  w.  j av a2 s .c  o  m*/
    }
    for (Object o : msgContentsNodes) {
        Node node = (Node) o;
        String tagText = node.selectSingleNode("TagText").getText();
        String reqd = node.selectSingleNode("Reqd").getText();
        if (allFields.containsKey(tagText)) {
            ComponentField componentField = new ComponentField(allFields.get(tagText), reqd);
            component.addMsgContent(componentField);
            System.out.println(prefix + "\t " + allFields.get(tagText).getFieldName());
        } else if (allComponents.containsKey(tagText)) {
            // Handle msgContents for the component in question first!
            addComponentMsgContent(allComponents.get(tagText), prefix + "\t");
            ComponentComponent componentComponent = new ComponentComponent(allComponents.get(tagText), reqd);
            component.addMsgContent(componentComponent);
            System.out.println(prefix + "\t " + allComponents.get(tagText).getName());
        } else {
            System.err.println("Could not find tagText: " + tagText);
        }
    }
}