Package com.volantis.mcs.xml.xpath

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


        }

        // javadoc inherited
        public void reportError(ErrorDetails details) {

            XPath xpath = details.getXPath();
            String key = details.getKey();
            String param = details.getParam();

            if (errorCount >= expectedErrors.length) {
                // we have received an error and there is no unprocessed
                // expected errors. The client has not expected this error at
                // all. Fail the test
                fail("Unexpected error has been reported xpath[" +
                     xpath.getExternalForm() + "], key[" + key +
                     "] and param[" + param + "]");
            }
            // check the reported error against the one that the client expects
            ExpectedError expected = expectedErrors[errorCount++];
            expected.assertXPath(xpath.getExternalForm());
            expected.assertKey(key);
            expected.assertParam(param);
        }
View Full Code Here


                    append(DeviceRepositorySchemaConstants.
                    POLICY_ELEMENT_NAME);
            xPathBuffer.append("[@").append(DeviceRepositorySchemaConstants.
                    POLICY_NAME_ATTRIBUTE).append("=\"").append(policyName).
                    append("\"]");
            XPath policyXPath = new XPath(xPathBuffer.toString(),
                    new Namespace[]{MCSNamespace.DEVICE_DEFINITIONS});
            Element policyElement =
                    policyXPath.selectSingleElement(getDeviceDefinitionsDocument().
                    getRootElement());

            if (policyElement == null) {
                throw new IllegalArgumentException("Could not find policy " +
                        policyName);
            }

            // Obtain the master device element from the hierarcrhy,
            xPathBuffer = new StringBuffer();
            xPathBuffer.append("//").//$NON-NLS-1$
                    append(MCSNamespace.DEVICE_HIERARCHY.getPrefix()).
                    append(':').
                    append(DeviceRepositorySchemaConstants.
                    DEVICE_ELEMENT_NAME);
            xPathBuffer.append("[@").append(DeviceRepositorySchemaConstants.
                    DEVICE_NAME_ATTRIBUTE).append("=\"").append(retrieveRootDeviceName()).
                    append("\"]");
            XPath masterXPath = new XPath(xPathBuffer.toString(),
                    new Namespace[]{MCSNamespace.DEVICE_HIERARCHY});
            Element masterElement =
                    masterXPath.selectSingleElement(getDeviceHierarchyDocument().
                    getRootElement());

            // Iterate over all the devices in the repository and remove the
            // policy from any device that includes it.
            removePolicyFromDeviceHierarchical(masterElement, policyName);
View Full Code Here

            StringBuffer buffer = new StringBuffer("//").append(NAMESPACE_PREFIX);
            buffer.append(':')
                    .append(DeviceRepositorySchemaConstants.POLICY_ELEMENT_NAME)
                    .append("[@name=\"").append(policy).append("\"]");

            XPath xpath = new XPath(buffer.toString(),
                    new Namespace[]{Namespace.getNamespace(
                            NAMESPACE_PREFIX,
                            definitionsRoot.getNamespaceURI())
                    });

            Element policyElement = null;
            try {
                policyElement =
                        (Element) xpath.selectSingleNode(definitionsRoot);
            } catch (XPathException e) {
                throw new IllegalArgumentException("Cannot find policy " +
                        "element named " + policy);
            }
View Full Code Here

                append("\"]/ns:type");
        // bind the "ns" prefix to the rootElements namespace.
        Namespace[] namespaces = new Namespace[]{
            Namespace.getNamespace("ns", rootElement.getNamespaceURI())
        };
        XPath xpath = new XPath(buffer.toString(), namespaces);
        try {
            policyTypeElement = xpath.selectSingleElement(rootElement);
            // see if the type element has a "ref" attribute
            if (policyTypeElement != null) {
                String ref = policyTypeElement.getAttributeValue(
                        DeviceRepositorySchemaConstants.
                        POLICY_DEFINITION_REF_ATTRIBUTE_NAME);
                // if the type element has a ref attribute then the attributes
                // value, references a named type whose definition can be
                // obtainded from the /definitions/types element.
                if (ref != null) {
                    // this is referencing a type that is defined in the
                    // types element
                    buffer = new StringBuffer();
                    buffer.append("/ns:definitions/ns:types/ns:type[@name=\"")
                            .append(ref)
                            .append("\"]");
                    xpath = new XPath(buffer.toString(), namespaces);
                    policyTypeElement = xpath.selectSingleElement(rootElement);
                }
            }
        } catch (XPathException e) {
            // There was a problem retrieving the type element.
            throw new UndeclaredThrowableException(e, e.getMessage());
View Full Code Here

        // based on the value of its name attribute.
        StringBuffer categoryBuffer = new StringBuffer(NAMESPACE_PREFIX);
        categoryBuffer.append(':')
                .append(DeviceRepositorySchemaConstants.CATEGORY_ELEMENT_NAME)
                .append("[@name=\"").append(categoryName).append("\"]");
        XPath xpath = new XPath(categoryBuffer.toString(),
                new Namespace[]{Namespace.getNamespace(
                        NAMESPACE_PREFIX,
                        rootElement.getNamespaceURI())
                });

        Element categoryElement = null;
        try {
            categoryElement =
                    (Element) xpath.selectSingleNode(rootElement);
        } catch (XPathException e) {
            throw new IllegalArgumentException("Cannot find category " +
                    "named " + categoryName);
        }
View Full Code Here

        StringBuffer buffer =
                new StringBuffer(grid.getNamespacePrefix().length() + 1 +
                gridRowElement.getName().length());
        buffer.append(grid.getNamespacePrefix()).append(":").
                append(gridRowElement.getName());
        XPath gridRows = new XPath(buffer.toString(),
                new Namespace[] { grid.getNamespace() });

        List gridRowFormats;
        try {
            gridRowFormats = gridRows.selectNodes(grid);
        } catch (XPathException e) {
            throw new UndeclaredThrowableException(e);
        }

        return gridRowFormats;
View Full Code Here

                    element.getNamespaceURI());

                // This path looks for all instances of the named element
                // somewhere below the context node (i.e. the element passed
                // into the {@link XPath#selectNodes} method
                xpath = new XPath(
                    new StringBuffer(".//"). //$NON-NLS-1$
                    append(PREFIX).
                    append(':').
                    append(lastElementName).toString(),
                    namespaces);
            }

            // Execute the XPath to select all required decendent nodes
            try {
                decendents = xpath.selectNodes(ancestor);
            } catch (XPathException e) {
                throw new UndeclaredThrowableException(e);
            }

            // Check the count limit constraint
            if (decendents.size() > maxCount) {
                result = true;

                if (errorReporter != null) {
                    // @todo it would be nice to pass actual and max counts
                    ErrorDetails details = new ErrorDetails(element, new XPath(element),
                            null, errorKey, ancestorElementName, null);
                    errorReporter.reportError(details);
                }
            }
        }
View Full Code Here

    public void copySelectionToClipboard(ODOMActionDetails details,
                                         String transferId) {
        ODOMElement[] clones = details.getElementsClone();
        for (int i = 0; i < clones.length; i++) {
            final String xpath =
                    new XPath(details.getElement(i)).getExternalForm();
            clones[i].setAttribute(XPATH, xpath);
        }
        Object[] values = {clones};

        Transfer[] types = {
View Full Code Here

                                    append("[@").
                                    append(DeviceRepositorySchemaConstants.
                                    DEVICE_NAME_ATTRIBUTE).
                                    append("=\"").append(newDeviceName).
                                    append("\"]");
                            final XPath newDeviceXPath =
                                    new XPath(newDeviceXPathBuffer.toString(),
                                            new Namespace[]{MCSNamespace.
                                    DEVICE_HIERARCHY});

                            Element newDeviceElement = null;
                            try {
                                // Get the hierarchy root for the XPath search.
                                final Element hierarchyRoot = dram.
                                        getDeviceHierarchyDocument().
                                        getRootElement();

                                // Retrieve the new device element.
                                newDeviceElement = newDeviceXPath.
                                        selectSingleElement(hierarchyRoot);
                            } catch (XPathException e) {
                                EclipseCommonPlugin.
                                        handleError(ABPlugin.getDefault(), e);
                            }
View Full Code Here

                // Form an XPath that starts with a context of the source
                // element (in the sense of source/target pair) and navigates
                // down to the EVENT source element via the element that has
                // had an element added to it
                final XPath testPathToAddition =
                    (sourceElement == event.getNewValue() ?
                        null :
                        new XPath(sourceElement,
                                  (Element) event.getNewValue()));
                final XPath testPathToEventSrc =
                    new XPath(testPathToAddition, eventSrcElement.getName());

                // If the above path matches our own path for mapping from
                // source (in the sense of source/target pair) to TARGET, then
                // it's established that the EVENT source is indeed a target
                if (testPathToEventSrc.externalFormsEqual(sourceToTargetPath)) {

                    // Target addition: make sure we don't already have one
                    if (existingProxyTarget != null) {
                        throw new IllegalStateException("Double target");
                    }
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.