Example usage for org.w3c.dom Document getDocumentURI

List of usage examples for org.w3c.dom Document getDocumentURI

Introduction

In this page you can find the example usage for org.w3c.dom Document getDocumentURI.

Prototype

public String getDocumentURI();

Source Link

Document

The location of the document or null if undefined or if the Document was created using DOMImplementation.createDocument.

Usage

From source file:de.interactive_instruments.etf.testdriver.te.TeTestTask.java

private void parseTestNgResult(final Document document) throws Exception {
    getLogger().info("Transforming results.");
    final Element result = document.getDocumentElement();
    if (!"testng-results".equals(result.getNodeName())) {
        throw new ParseException("Expected a TestNG result XML", document.getDocumentURI(), 0);
    }/*from  w  w w.j a  v a 2s .c  o m*/

    final String failedAssertions = XmlUtils.getAttribute(result, "failed");
    final String passedAssertions = XmlUtils.getAttribute(result, "passed");
    final Integer passedAssertionsInt = Integer.valueOf(passedAssertions);
    getLogger().info("{} of {} assertions passed", passedAssertionsInt,
            Integer.valueOf(passedAssertions + Integer.valueOf(failedAssertions)));

    final TestResultCollector resultCollector = getCollector();

    final Node suiteResult = XmlUtils.getFirstChildNodeOfType(result, ELEMENT_NODE, "suite");
    resultCollector.startTestTask(testTaskDto.getExecutableTestSuite().getId().getId(),
            getStartTimestamp(suiteResult));

    // Save result document as attachment
    final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    final Source xmlSource = new DOMSource(document);
    final Result outputTarget = new StreamResult(outputStream);
    TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
    final InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    resultCollector.saveAttachment(inputStream, "TEAM Engine result", "text/xml", "TestNgResultXml");

    // Test Modules
    for (Node testModule = XmlUtils.getFirstChildNodeOfType(suiteResult, ELEMENT_NODE,
            "test"); testModule != null; testModule = XmlUtils.getNextSiblingOfType(testModule, ELEMENT_NODE,
                    "test")) {
        final String testModuleId = getItemID(testModule);
        resultCollector.startTestModule(testModuleId, getStartTimestamp(testModule));

        // Test Cases
        for (Node testCase = XmlUtils.getFirstChildNodeOfType(testModule, ELEMENT_NODE,
                "class"); testCase != null; testCase = XmlUtils.getNextSiblingOfType(testCase, ELEMENT_NODE,
                        "class")) {
            final String testCaseId = getItemID(testCase);

            // Get start timestamp from first test step
            final Node firstTestStep = XmlUtils.getFirstChildNodeOfType(testCase, ELEMENT_NODE, "test-method");
            if (firstTestStep != null) {
                resultCollector.startTestCase(testCaseId, getStartTimestamp(firstTestStep));
            } else {
                resultCollector.startTestCase(testCaseId);
            }
            long testCaseEndTimeStamp = 0;
            boolean testStepResultCollected = false;
            boolean oneSkippedOrNotApplicableConfigStepRecorded = false;

            // Test Steps (no Test Assertions are used)
            for (Node testStep = firstTestStep; testStep != null; testStep = XmlUtils
                    .getNextSiblingOfType(testStep, ELEMENT_NODE, "test-method")) {

                final long testStepEndTimestamp = getEndTimestamp(testStep);
                if (testCaseEndTimeStamp < testStepEndTimestamp) {
                    testCaseEndTimeStamp = testStepEndTimestamp;
                }

                final int status = mapStatus(testStep);
                final boolean configStep = "true"
                        .equals(XmlUtils.getAttributeOrDefault(testStep, "is-config", "false"));

                // output only failed steps or only one skipped or not applicable config test step
                if (!configStep || status == 1
                        || (!oneSkippedOrNotApplicableConfigStepRecorded && status == 2 || status == 3)) {
                    final long testStepStartTimestamp = getStartTimestamp(testStep);
                    final String testStepId = getItemID(testStep);
                    resultCollector.startTestStep(testStepId, testStepStartTimestamp);

                    final String message = getMessage(testStep);
                    if (!SUtils.isNullOrEmpty(message)) {
                        resultCollector.addMessage("TR.teamEngineError", "error", message);
                    }

                    // Attachments
                    for (Node attachments = XmlUtils.getFirstChildNodeOfType(testStep, ELEMENT_NODE,
                            "attributes"); attachments != null; attachments = XmlUtils
                                    .getNextSiblingOfType(attachments, ELEMENT_NODE, "attributes")) {
                        for (Node attachment = XmlUtils.getFirstChildNodeOfType(attachments, ELEMENT_NODE,
                                "attribute"); attachment != null; attachment = XmlUtils
                                        .getNextSiblingOfType(attachment, ELEMENT_NODE, "attribute")) {
                            final String type = XmlUtils.getAttribute(attachment, "name");
                            switch (type) {
                            case "response":
                                final String response = XmlUtils.nodeValue(attachment);
                                resultCollector.saveAttachment(IOUtils.toInputStream(response, "UTF-8"),
                                        "Service Response", XmlUtils.isWellFormed(response) ? "text/xml" : null,
                                        "ServiceResponse");
                                break;
                            case "request":
                                final String request = XmlUtils.nodeValue(attachment);
                                if (XmlUtils.isWellFormed(request)) {
                                    resultCollector.saveAttachment(
                                            IOUtils.toInputStream(XmlUtils.nodeValue(attachment), "UTF-8"),
                                            "Request Parameter", "text/xml", "PostData");
                                } else {
                                    resultCollector.saveAttachment(XmlUtils.nodeValue(attachment),
                                            "Request Parameter", "text/plain", "GetParameter");
                                }
                                break;
                            default:
                                resultCollector.saveAttachment(XmlUtils.nodeValue(attachment), type, null,
                                        type);
                            }
                        }
                    }
                    resultCollector.end(testStepId, status, testStepEndTimestamp);
                    if (configStep && (status == 2 || status == 3)) {
                        oneSkippedOrNotApplicableConfigStepRecorded = true;
                    }
                    testStepResultCollected = true;
                }
            }
            if (testStepResultCollected) {
                resultCollector.end(testCaseId, testCaseEndTimeStamp);
            } else {
                // only passed config steps collected,
                resultCollector.end(testCaseId, 0, testCaseEndTimeStamp);
            }
        }
        resultCollector.end(testModuleId, getEndTimestamp(testModule));
    }
    resultCollector.end(testTaskDto.getId().getId(), getEndTimestamp(suiteResult));
}

From source file:net.sourceforge.dita4publishers.impl.dita.InMemoryDitaLinkManagementService.java

/**
 * @param user//from w w w  .j a v  a 2  s .  co m
 * @param keydefContext
 * @param key
 * @param seenKeyDefs
 * @return
 * @throws DitaApiException 
 */
private DitaResource resolveKeyToResource(KeyAccessOptions keyAccessOptions,
        DitaKeyDefinitionContext keydefContext, String key, List<DitaKeyDefinition> seenKeyDefs)
        throws DitaApiException {
    DitaKeyDefinition keyDef = getKeyDefinition(keyAccessOptions, keydefContext, key);
    if (seenKeyDefs.contains(keyDef)) {
        Document rootMap = getRootMapForContext(keyAccessOptions, keydefContext);
        throw new DitaApiException("Circular reference to key \"" + key + "\" in key space defined by map "
                + rootMap.getDocumentURI() + "], initial" + "key definition defines the key: \""
                + seenKeyDefs.get(0).getKey());
    }
    String keyref = keyDef.getKeyref();
    DitaResource res = null;
    if (keyref != null) {
        if (keyref.equals(key)) {
            Document rootMap = getRootMapForContext(keyAccessOptions, keydefContext);
            throw new DitaApiException("Key definition refers to itself: key \"" + key
                    + "\" in key space defined by map " + rootMap.getDocumentURI());
        }
        res = resolveKeyToResource(keyAccessOptions, keydefContext, keyref, seenKeyDefs);
    }

    if (res != null)
        return res;

    String href = keyDef.getHref();
    if (href != null)
        return resolveHrefToResource(keyAccessOptions, keyDef, href);

    // If we get here, no keyref or href, look for linktext subelement.

    Element elem = null;

    return new DitaElementResourceImpl(elem);
}

From source file:net.sourceforge.dita4publishers.impl.ditabos.DitaTreeWalkerBase.java

/**
 * @param bos/*from  w w  w.  ja v  a 2s  . com*/
 * @param object
 * @param elem
 * @param level
 * @throws Exception 
 */
protected void walkMapCalcMapTree(BoundedObjectSet bos, XmlBosMember currentMember, Document mapDoc, int level)
        throws Exception {
    String levelSpacer = getLevelSpacer(level);

    log.debug("walkMap(): " + levelSpacer + "Walking map  " + mapDoc.getDocumentURI() + "...");

    Element mapRoot = mapDoc.getDocumentElement();

    NodeList resultNl;
    try {
        resultNl = (NodeList) DitaUtil.allTopicrefsWithHrefs.evaluate(mapRoot, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        throw new BosException(
                "XPath exception evaluating XPath against a DITA map managed object: " + e.getMessage(), e);
    }

    List<Document> childMaps = new ArrayList<Document>();

    for (int i = 0; i < resultNl.getLength(); i++) {
        Element topicRef = (Element) resultNl.item(i);
        if (DitaUtil.isMapReference(topicRef)) {
            String href = topicRef.getAttribute("href");
            log.debug("walkMap(): " + levelSpacer + "  handling map reference to href \"" + href + "\"...");
            Document targetDoc = null;
            try {
                targetDoc = AddressingUtil.resolveHrefToDoc(topicRef, href, bosConstructionOptions,
                        this.failOnAddressResolutionFailure);
            } catch (Exception e) {
                throw new BosException("Exception resolving href: " + e.getMessage(), e);
            }
            if (targetDoc != null) {
                childMaps.add(targetDoc);
            } else {
                throw new BosException("Failed to resolve @href value \"" + href
                        + "\" to a managed object from map " + mapDoc.getDocumentURI());
            }
        }
    }

    log.debug("walkMap(): " + levelSpacer + "  Found " + childMaps.size() + " child maps.");

    // Now we have a list of the child maps in document order by reference.
    // Iterate over them to update the key space:

    if (childMaps.size() > 0) {
        log.debug("walkMap(): " + levelSpacer + "  Adding key definitions from child maps...");

        for (Document childMap : childMaps) {
            keySpace.addKeyDefinitions(childMap.getDocumentElement());
        }

        // Now walk each of the maps to process the next level in the map hierarchy:

        log.debug("walkMap(): " + levelSpacer + "  Walking child maps...");
        for (Document childMapDoc : childMaps) {
            XmlBosMember childMember = bos.constructBosMember(currentMember, childMapDoc);
            bos.addMember(currentMember, childMember);
            walkMapCalcMapTree(bos, childMember, childMapDoc, level + 1);
        }
        log.debug("walkMap(): " + levelSpacer + "  Done walking child maps");
    }

}

From source file:net.sourceforge.dita4publishers.impl.dita.InMemoryDitaLinkManagementService.java

public void unRegisterRootMap(Document rootMap) throws DitaApiException {
    DitaKeyDefinitionContext context = this.getKeyDefinitionContext(rootMap);
    if (this.keyspaceCache.containsKey(context)) {
        log.info("unRegisterRootMap(): Key space registered, removing...");
        this.keyspaceCache.remove(context);
        this.contexts.remove(rootMap.getDocumentURI());
    } else {//from w  ww  .j  a  v  a  2 s. c o  m
        log.info("registerRootMap(): Key space for root map not found.");
    }

}

From source file:de.unibi.techfak.bibiserv.BiBiTools.java

/**
 * Static Method paramdoc2list converts a param DOM document of the form :
 *
 * <pre>/*from  www  .j a v a  2  s .  c om*/
 *  &lt;param>&gt;s
 *    &lt;param_key&gt;param_value&lt;/param_key&gt;>
 *    &lt;param_key>&gt;param_value2&lt;/param_key&gt;>
 *    ...
 *    &lt;param_key2&gt;>param_value3&lt;/param_key&gt;>
 *    ...
 * </pre>
 *
 * to a list of Pair<String,String> objects.
 *
 * @param paramdoc DOM document containing parameter as key/value pairs ...
 *
 * @return Returns a list of Pair<String,String> objects
 */
public static List<Pair<String, String>> paramdoc2List(Document paramdoc) {
    List<Pair<String, String>> list = new ArrayList<>();

    /* the param document should contain only param tag, which is the root tag */
    Element paramroot = (Element) paramdoc.getElementsByTagName("param").item(0);
    if (paramroot != null) {
        /* save all child node as HashMap Elements */
        NodeList paramlist = paramroot.getChildNodes();
        /* iterate over all element nodes */
        for (int i = 0; i < paramlist.getLength(); ++i) {
            Node param = paramlist.item(i);
            if (param.getNodeType() == Node.ELEMENT_NODE) {
                /* the name of the tag is the name of the parameter
                the text content is the value */
                Pair pair = new Pair(param.getNodeName(), param.getTextContent());
                list.add(pair);
            }
        }
    } else {
        log.warn("Document '" + paramdoc.getDocumentURI() + "' does not contain a param tag!");
    }
    return list;
}

From source file:net.sourceforge.dita4publishers.impl.ditabos.DitaTreeWalkerBase.java

/**
 * @param bos/*from   w  w w . j  a va  2 s.  com*/
 * @param member
 * @param newMembers
 * @throws Exception 
 */
protected void findLinkDependencies(BoundedObjectSet bos, XmlBosMember member, Set<BosMember> newMembers)
        throws Exception {
    NodeList links;
    try {
        links = (NodeList) DitaUtil.allHrefsAndKeyrefs.evaluate(member.getElement(), XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        throw new BosException("Unexcepted exception evaluating xpath " + DitaUtil.allTopicrefs);
    }

    log.debug("findLinkDependencies(): Found " + links.getLength() + " href- or keyref-using elements");

    for (int i = 0; i < links.getLength(); i++) {
        Element link = (Element) links.item(i);
        Document targetDoc = null;
        URI targetUri = null;
        String dependencyKey = null; // Original href or keyref value

        // If there is a key reference, attempt to resolve it,
        // then fall back to href, if any.
        String href = null;
        DependencyType depType = Constants.LINK_DEPENDENCY;
        if (DitaUtil.isDitaType(link, "topic/image")) {
            depType = Constants.IMAGE_DEPENDENCY;
        } else if (DitaUtil.isDitaType(link, "topic/xref")) {
            depType = Constants.XREF_DEPENDENCY;
        }
        try {
            if (link.hasAttribute("keyref")) {
                log.debug("findLinkDependencies(): resolving reference to key \"" + link.getAttribute("keyref")
                        + "\"...");
                if (!DitaUtil.targetIsADitaFormat(link) || DitaUtil.isDitaType(link, "topic/image")) {
                    targetUri = resolveKeyrefToUri(link.getAttribute("keyref"));
                } else {
                    targetDoc = resolveKeyrefToDoc(link.getAttribute("keyref"));
                }
            }
            if (targetUri == null && targetDoc == null && link.hasAttribute("href")) {
                log.debug("findLinkDependencies(): resolving reference to href \"" + link.getAttribute("href")
                        + "\"...");
                href = link.getAttribute("href");
                dependencyKey = href;
                if (DitaUtil.isDitaType(link, "topic/image")) {
                    targetUri = AddressingUtil.resolveHrefToUri(link, link.getAttribute("href"),
                            this.failOnAddressResolutionFailure);
                } else if (!DitaUtil.targetIsADitaFormat(link) && DitaUtil.isLocalOrPeerScope(link)) {
                    targetUri = AddressingUtil.resolveHrefToUri(link, link.getAttribute("href"),
                            this.failOnAddressResolutionFailure);
                } else {
                    // If we get here, isn't an image reference and is presumably a DITA format resource.
                    // Don't bother with links within the same XML document.
                    if (!href.startsWith("#") && DitaUtil.isLocalOrPeerScope(link)) {
                        targetDoc = AddressingUtil.resolveHrefToDoc(link, link.getAttribute("href"),
                                bosConstructionOptions, this.failOnAddressResolutionFailure);
                    }

                }
            } else {
                dependencyKey = AddressingUtil.getKeyNameFromKeyref(link);
            }
        } catch (AddressingException e) {
            if (this.failOnAddressResolutionFailure) {
                throw new BosException(
                        "Failed to resolve href \"" + link.getAttribute("href") + "\" to a managed object", e);
            }
        }

        if (targetDoc == null && targetUri == null || targetDoc == member.getDocument())
            continue;

        BosMember depMember = null;
        if (targetDoc != null) {
            log.debug("findLinkDependencies(): Got document \"" + targetDoc.getDocumentURI() + "\"");
            depMember = bos.constructBosMember(member, targetDoc);
        } else if (targetUri != null) {
            log.debug("findLinkDependencies(): Got URI \"" + targetUri.toString() + "\"");
            depMember = bos.constructBosMember((BosMember) member, targetUri);
        }
        newMembers.add(depMember);
        bos.addMemberAsDependency(dependencyKey, depType, member, depMember);
    }

}

From source file:org.dita2indesign.indesign.builders.InDesignFromDitaMapBuilder.java

/**
 * Applies the specified transform to the map document in order to generate
 * InCopy articles for the topics in the map. 
 * @param mapDoc//w ww.j a v  a  2s.  co  m
 * @param options Options used to configure the transform, including the URL of the 
 * transform itself.
 * @throws Exception 
 */
private void generateInCopyArticlesForTopics(Document mapDoc, Map2InDesignOptions options) throws Exception {

    URL xsltUrl = options.getXsltUrl();
    if (xsltUrl == null) {
        throw new Exception("No XSLT URL option value specified.");
    }

    Source style = new StreamSource(xsltUrl.openStream());
    style.setSystemId(xsltUrl.toExternalForm());

    Source xmlSource = new DOMSource(mapDoc);
    String mapDocUri = mapDoc.getDocumentURI();
    xmlSource.setSystemId(mapDocUri);
    if (log.isDebugEnabled())
        log.debug("xmlSource.systemId=\"" + xmlSource.getSystemId() + "\"");
    // Create a temp file in the same directory as the real INX file so the 
    // XSLT transform will generate its output in the right place:
    File resultFile = File.createTempFile("map2indesign", ".inx", options.getResultFile().getParentFile()); // NOTE: The top-level file is not used.

    if (log.isDebugEnabled())
        log.debug("Calling transform()...");

    Source xsltSource = new StreamSource(xsltUrl.openStream());
    xsltSource.setSystemId(xsltUrl.toExternalForm());

    XsltTransformer trans = getSaxonTransformer(xmlSource, resultFile, xsltSource);

    trans.setParameter(new QName("styleCatalogUrl"), new XdmAtomicValue(options.getStyleCatalogUrl()));
    trans.setParameter(new QName("outputPath"), new XdmAtomicValue(resultFile.getParent()));
    trans.setParameter(new QName("linksPath"), new XdmAtomicValue(options.getLinksPath()));
    trans.setParameter(new QName("debug"), new XdmAtomicValue(options.getDebug()));

    trans.transform();
    if (log.isDebugEnabled())
        log.debug("Transformation complete.");
    resultFile.delete(); // Don't need the result file since each article is generated as a separate file.
}

From source file:org.jboss.shrinkwrap.descriptor.metadata.MetadataParser.java

/**
 * Parses one or more XSD schemas or DTD and produces java classes based on the parsing results.
 *
 * @param path/*from ww w  .  ja v a2  s.  com*/
 *            specifies where to create the interface, implementation and test case java classes.
 * @param confList
 *            list <code>MetadataParserConfiguration</code> objects.
 * @param verbose
 *            if true, additional parsing information are printed out, otherwise not.
 * @throws Exception
 */
@SuppressWarnings("unchecked")
public void parse(final MetadataParserPath path, final List<?> confList, final List<?> javadocTags,
        final boolean verbose) throws Exception {
    checkArguments(path, confList);

    pathToMetadata = createTempFile(verbose);

    if (log.isLoggable(Level.FINE)) {
        log.fine("Path to temporary metadata file: " + pathToMetadata);
    }

    for (int i = 0; i < confList.size(); i++) {
        final MetadataParserConfiguration metadataConf = (MetadataParserConfiguration) confList.get(i);

        metadata.setCurrentNamespace(metadataConf.getNameSpace());
        metadata.setCurrentSchmema(metadataConf.getPathToXsd());
        metadata.setCurrentPackageApi(metadataConf.getPackageApi());
        metadata.setCurrentPackageImpl(metadataConf.getPackageImpl());

        final MetadataDescriptor metadataDescriptor = new MetadataDescriptor(metadataConf.getDescriptorName());
        metadataDescriptor.setRootElementName(metadataConf.getElementName());
        metadataDescriptor.setRootElementType(metadataConf.getElementType());
        metadataDescriptor.setSchemaName(metadataConf.getPathToXsd());
        metadataDescriptor.setPackageApi(metadataConf.getPackageApi());
        metadataDescriptor.setPackageImpl(metadataConf.getPackageImpl());
        metadataDescriptor.setNamespace(metadataConf.getNameSpace());
        metadataDescriptor.setNamespaces(metadataConf.getNamespaces());
        metadataDescriptor.setGenerateClasses(metadataConf.generateClasses);
        metadataDescriptor.setPathToPackageInfoApi(metadataConf.getPathToPackageInfoApi());
        metadataDescriptor.setPathToPackageInfoImpl(metadataConf.getPathToPackageInfoImpl());
        metadataDescriptor.setCommon(metadataConf.getCommon());
        metadataDescriptor.setCommonRef(metadataConf.getCommonRef());
        metadataDescriptor.setGenerateCommonClasses(metadataConf.generateCommonClasses);
        metadataDescriptor.setCommonImports(metadataConf.getCommonImports());

        metadata.getMetadataDescriptorList().add(metadataDescriptor);

        if (log.isLoggable(Level.FINE)) {
            log.fine(metadataConf.getPathToXsd());
        }

        if (metadataConf.getPathToXsd().endsWith(".dtd")) {
            final InputSource in = new InputSource(new FileReader(metadataConf.getPathToXsd()));
            final MetadataDtdEventListener dtdEventListener = new MetadataDtdEventListener(metadata, verbose);
            final DTDParser parser = new DTDParser();
            parser.setDtdHandler(dtdEventListener);
            parser.parse(in);
        } else {
            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            final DocumentBuilder loader = factory.newDocumentBuilder();
            final Document document = loader.parse(metadataConf.getPathToXsd());

            if (log.isLoggable(Level.FINE)) {
                log.fine(document.getDocumentURI());
            }

            final DocumentTraversal traversal = (DocumentTraversal) document;
            final TreeWalker walker = traversal.createTreeWalker(document.getDocumentElement(),
                    NodeFilter.SHOW_ELEMENT, null, true);

            final StringBuilder sb = verbose ? new StringBuilder() : null;

            filterChain.traverseAndFilter(walker, "", metadata, sb);

            if (sb != null) {
                log.info(sb.toString());
            }
        }
    }

    /**
     * Analyze the data types defined in the elements. If an element data types points to a type defined in the data
     * type section, and the data type is simple type like xsd:string then change the element data type directly
     * here.
     */
    metadata.preResolveDataTypes();

    if (pathToMetadata != null) {
        new DomWriter().write(metadata, pathToMetadata, (List<MetadataJavaDoc>) javadocTags);
    }

    if (verbose) {
        new MetadataUtil().log(metadata);
    }

    if (path.getPathToApi() != null && path.getPathToImpl() != null) {
        generateCode(path, verbose);
        PackageInfo.copyPackageInfo(path, metadata, verbose);
    }
}

From source file:org.tinygroup.jspengine.xmlparser.ParserUtils.java

private static Schema getSchema(Document document) throws SAXException, JasperException {

    Schema schema = null;//  ww  w.ja  v  a 2  s  .  c o m
    Element root = document.getDocumentElement();
    NamedNodeMap map = root.getAttributes();
    for (int i = 0; map != null && i < map.getLength(); i++) {
        if (SCHEMA_LOCATION_ATTR.equals(map.item(i).getLocalName())) {
            String schemaLocation = map.item(i).getNodeValue();
            if (Constants.SCHEMA_LOCATION_JSP_20.equals(schemaLocation)) {
                schema = getSchema(Constants.TAGLIB_SCHEMA_PUBLIC_ID_20);
                break;
            } else if (Constants.SCHEMA_LOCATION_JSP_21.equals(schemaLocation)) {
                schema = getSchema(Constants.TAGLIB_SCHEMA_PUBLIC_ID_21);
                break;
            } else if (Constants.SCHEMA_LOCATION_WEBAPP_24.equals(schemaLocation)) {
                schema = getSchema(Constants.WEBAPP_SCHEMA_PUBLIC_ID_24);
                break;
            } else if (Constants.SCHEMA_LOCATION_WEBAPP_25.equals(schemaLocation)) {
                schema = getSchema(Constants.WEBAPP_SCHEMA_PUBLIC_ID_25);
                break;
            } else {
                throw new JasperException(Localizer.getMessage("jsp.error.parse.unknownTldSchemaLocation",
                        document.getDocumentURI(), map.item(i).getNodeValue()));
            }
        }
    }

    return schema;
}

From source file:org.wso2.carbon.is.migration.service.v550.migrator.EventPublisherMigrator.java

private NodeList getEncryptedPayload(Document doc, XPath xpath) throws Exception {

    try {// www  .  j a  va 2  s  .  c o  m
        XPathExpression expr = xpath
                .compile("//*[local-name()='property'][@*[local-name()='encrypted']='true']/text()");
        return (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
    } catch (XPathExpressionException e) {
        throw new MigrationClientException(
                "Error has occurred while retriving the payload from file : " + doc.getDocumentURI(), e);
    }

}