Package com.volantis.mcs.xml.xpath

Examples of com.volantis.mcs.xml.xpath.XPath


            // this should never happen
            throw new IllegalStateException("DOMValidator is null");
        }

        // get the XPath for the marker
        XPath xPath = errorReporter.getXPath(marker);

        // We don't need to do anything with a null XPath since means
        // we cannot set the focus. For example, the policy name (file name
        // is invalid => there is no editor for file names and no way
        // to set the focus).
View Full Code Here


     * Must not be null.
     */
    protected void setFocus(XPath xPath) {

        try {
            XPath elementPath = xPath;
            // get a context and trim the attribute from the XPath
            Element root = getODOMEditorContext().getRootElement();
            if (elementPath.getDOMType() != DOMType.ELEMENT_TYPE) {
                elementPath = elementPath.getParent();
            }

            // select the correct component
            context.getODOMSelectionManager()
                    .setSelection(elementPath.selectNodes(root));
            XPathFocusable[] focusableControls = getXPathFocusableControls();
            for (int i = 0; (focusableControls != null) &&
                    (i < focusableControls.length); i++) {
                focusableControls[i].setFocus(xPath);
            }
View Full Code Here

        }

        // Validate that the element has content that is non-whitespace
        Iterator contents = element.getContent().iterator();
        if (!contents.hasNext()) {
            ErrorDetails details = new ErrorDetails(element, new XPath(element),
                    null, FaultTypes.WHITESPACE, null, null);
            errorReporter.reportError(details);
        } else {
            do {
                Object content = contents.next();
                if (content == null || ((Text) content).getText().trim().
                        length() == 0) {
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, FaultTypes.WHITESPACE, null, null);
                    errorReporter.reportError(details);
                }
            } while (contents.hasNext());
        }
View Full Code Here

        xpathString.append("ancestor::").
                append(MCSNamespace.DEVICE_DEFINITIONS.getPrefix()).
                append(":").
                append(DeviceRepositorySchemaConstants.POLICY_ELEMENT_NAME);

        XPath policyXPath = new XPath(xpathString.toString(), new Namespace [] {
            MCSNamespace.DEVICE_DEFINITIONS });
        Element policy = policyXPath.selectSingleElement(invalidElement);

        if (policy == null) {
            throw new XPathException("Selected element was null for xPath: " +
                    invalidElement.toString());
        }

        String policyName =
                policy.getAttributeValue(DeviceRepositorySchemaConstants.
                POLICY_NAME_ATTRIBUTE);

        xpathString = new StringBuffer();
        xpathString.append("ancestor::").
                append(MCSNamespace.DEVICE_DEFINITIONS.getPrefix()).
                append(":").
                append(DeviceRepositorySchemaConstants.CATEGORY_ELEMENT_NAME);

        XPath categoryXPath = new XPath(xpathString.toString(),
                new Namespace [] { MCSNamespace.DEVICE_DEFINITIONS });
        Element category = categoryXPath.selectSingleElement(policy);

        String categoryName =
                category.getAttributeValue(DeviceRepositorySchemaConstants.
                CATEGORY_NAME_ATTRIBUTE);
View Full Code Here

        if (details.getNumberOfElements() == 1 &&
                !details.getElement(0).getName().equals(
                        FormatType.EMPTY.getElementName())) {
            // If so, then determine if the source (from the clipboard) could
            // replace the selected content.
            final XPath sourceFormatXPath = recreateXPathForClipboardContent(
                    sourceFormat, MCSNamespace.LPDM);
            canEnable = ActionSupport.canReplace(sourceFormat,
                    details.getElement(0), sourceFormatXPath);
        }
        return canEnable;   
View Full Code Here

        xPathBuffer.append("//").//$NON-NLS-1$
                append(MCSNamespace.DEVICE.getPrefix()).
                append(':').
                append(DeviceRepositorySchemaConstants.
                POLICIES_ELEMENT_NAME);
        XPath policiesXPath = new XPath(xPathBuffer.toString(),
                new Namespace[]{MCSNamespace.DEVICE});

        try {
            Element policies = policiesXPath.
                    selectSingleElement(masterDevice);
            composition.addDefaultPolicyValue(policies, policyName, type,
                    context.getODOMFactory(),
                    context.getDeviceRepositoryAccessorManager());
        } catch (XPathException e) {
View Full Code Here

                append(DeviceRepositorySchemaConstants.POLICY_ELEMENT_NAME).
                append("[@").
                append(DeviceRepositorySchemaConstants.POLICY_NAME_ATTRIBUTE).
                append("=\"").append(newPolicyName).
                append("\"]");
        final XPath newPolicyXPath = new XPath(newPolicyXPathBuffer.toString(),
                new Namespace[]{MCSNamespace.DEVICE_DEFINITIONS});

        Element newPolicyElement = null;
        try {
            // Get the definitions root for the XPath search.
            final Element definitionsRoot = context.
                    getDeviceRepositoryAccessorManager().
                    getDeviceDefinitionsDocument().getRootElement();
            // Retrieve the new policy element.
            newPolicyElement =
                    newPolicyXPath.selectSingleElement(definitionsRoot);
        } catch (XPathException e) {
            EclipseCommonPlugin.handleError(ABPlugin.getDefault(), e);
        }

        TreeViewer treeViewer = categoriesComposite.getTreeViewer();
View Full Code Here

        if (details.getNumberOfElements() == 1 &&
                details.getElement(0).getName().equals(
                        FormatType.EMPTY.getElementName())) {
            // If so, then determine if the source (from the clipboard) could
            // replace the selected content.
            final XPath sourceFormatXPath = recreateXPathForClipboardContent(
                    sourceFormat, MCSNamespace.LPDM);
            canEnable = ActionSupport.canReplace(sourceFormat,
                    details.getElement(0), sourceFormatXPath);
        }
        return canEnable;
View Full Code Here

        final String externalForm =
                format.getAttribute(ClipboardSupport.XPATH).getValue();
        // Ensure that the xpath attribute does not appear in the output.
        format.removeAttribute(ClipboardSupport.XPATH);
        final Namespace[] namespaces = new Namespace[] {namespace};
        return new XPath(externalForm, namespaces);
    }
View Full Code Here

        // removed). An absolute path can be applied anywhere in the clone
        // document structure to find the equivalent element. This assumes that
        // the clone is really in a fully defined document (such as that
        // returned by {@link cloneContainingDeviceLayout}) with just one
        // device layout.
        XPath path = new XPath(original);

        // The device layout predicate must be removed from the path (the clone
        // will only have one device layout) if there is one
        String pathText = path.getExternalForm();
        int secondSeparator = pathText.indexOf('/', 1);

        if (secondSeparator > 0) {
            secondSeparator = pathText.indexOf('/', secondSeparator + 1);

            if (secondSeparator > 0) {
                char deviceLayoutPathEnd =
                        pathText.charAt(secondSeparator - 1);

                if (deviceLayoutPathEnd == ']') {
                    path = new XPath(
                            new StringBuffer(
                                    pathText.substring(0,
                                            pathText.indexOf('['))).
                            append(pathText.substring(secondSeparator)).
                            toString(),
                            path.getNamespacesString());
                }

                try {
                    // Get the equivalent element
                    equivalent = path.selectSingleElement(clone);
                } catch (XPathException e) {
                    throw new UndeclaredThrowableException(e);
                }
            }
        }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.xml.xpath.XPath

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.