当前位置: 首页>>代码示例>>Java>>正文


Java Document.getImplementation方法代码示例

本文整理汇总了Java中org.w3c.dom.Document.getImplementation方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getImplementation方法的具体用法?Java Document.getImplementation怎么用?Java Document.getImplementation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Document的用法示例。


在下文中一共展示了Document.getImplementation方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDocumentType

import org.w3c.dom.Document; //导入方法依赖的package包/类
private static DocumentType getDocumentType(Document doc) {
    DOMImplementation domImpl = doc.getImplementation();
    // <!DOCTYPE datafile PUBLIC "-//Logiqx//DTD ROM Management Datafile//EN" "http://www.logiqx.com/Dats/datafile.dtd">
    DocumentType doctype = domImpl.createDocumentType("datafile",
            "-//Logiqx//DTD ROM Management Datafile//EN",
            "http://www.logiqx.com/Dats/datafile.dtd");
    return doctype;
}
 
开发者ID:phweda,项目名称:MFM,代码行数:9,代码来源:PersistUtils.java

示例2: validateXmlResult

import org.w3c.dom.Document; //导入方法依赖的package包/类
private void validateXmlResult(Element resultXml) throws KalturaApiException {

        Element resultElement = null;
        try {
            resultElement = XmlUtils.getElementByXPath(resultXml, "/xml/result");
        } catch (XPathExpressionException xee) {
            // AZ (unicon) - necessary in order to debug 
            String resultXmlStr;
            try {
                Document document = resultXml.getOwnerDocument();
                DOMImplementationLS domImplLS = (DOMImplementationLS) document.getImplementation();
                LSSerializer serializer = domImplLS.createLSSerializer();
                resultXmlStr = serializer.writeToString(resultXml);
            } catch (Exception e) {
                resultXmlStr = "Unable to get XML result: "+e;
            }
            throw new KalturaApiException("XPath expression exception ("+xee+") evaluating result:"+resultXmlStr);
        }

        if (resultElement != null) {
            return;            
        } else {
        	throw new KalturaApiException("Invalid result");
        }
    }
 
开发者ID:ITYug,项目名称:kaltura-ce-sakai-extension,代码行数:26,代码来源:KalturaClientBase.java

示例3: main

import org.w3c.dom.Document; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.newDocument();

    DOMImplementation impl = document.getImplementation();
    DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
    LSSerializer dsi = implLS.createLSSerializer();

    /* We should have here incorrect document without getXmlVersion() method:
     * Such Document is generated by replacing the JDK bootclasses with it's
     * own Node,Document and DocumentImpl classes (see run.sh). According to
     * XERCESJ-1007 the AbstractMethodError should be thrown in such case.
     */
    String result = dsi.writeToString(document);
    System.out.println("Result:" + result);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AbstractMethodErrorTest.java

示例4: getGroupings

import org.w3c.dom.Document; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
   private void getGroupings(Integer organisationId, HttpServletResponse response) throws IOException {
Document doc = OrganisationGroupServlet.docBuilder.newDocument();
Element groupsElement = doc.createElement("groups");
doc.appendChild(groupsElement);

List<OrganisationGrouping> groupings = userManagementService.findByProperty(OrganisationGrouping.class,
	"organisationId", organisationId);
for (OrganisationGrouping grouping : groupings) {
    Element groupingElement = doc.createElement("grouping");
    groupingElement.setAttribute("id", grouping.getGroupingId().toString());
    groupingElement.setAttribute("name", StringEscapeUtils.escapeXml(grouping.getName()));
    groupsElement.appendChild(groupingElement);
    for (OrganisationGroup group : grouping.getGroups()) {
	Element groupElement = doc.createElement("group");
	groupElement.setAttribute("id", group.getGroupId().toString());
	groupElement.setAttribute("name", StringEscapeUtils.escapeXml(group.getName()));
	groupingElement.appendChild(groupElement);
	for (User user : group.getUsers()) {
	    Element userElement = doc.createElement("user");
	    userElement.setAttribute("id", user.getUserId().toString());
	    userElement.setAttribute("firstname", StringEscapeUtils.escapeXml(user.getFirstName()));
	    userElement.setAttribute("lastname", StringEscapeUtils.escapeXml(user.getLastName()));
	    groupElement.appendChild(userElement);
	}
    }
}

response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");

DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(response.getOutputStream());
lsSerializer.write(doc, lsOutput);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:OrganisationGroupServlet.java

示例5: elementToString

import org.w3c.dom.Document; //导入方法依赖的package包/类
private String elementToString(Element element) {
    Document document = element.getOwnerDocument();
    DOMImplementationLS domImplLS = (DOMImplementationLS) document
            .getImplementation();
    LSSerializer serializer = domImplLS.createLSSerializer();
    return serializer.writeToString(element);
}
 
开发者ID:MicroFocus,项目名称:octane-cucumber-jvm,代码行数:8,代码来源:FeatureElementTest.java

示例6: buildNodeString

import org.w3c.dom.Document; //导入方法依赖的package包/类
/**
 * Method to serialize a DOM Node to string.
 * 
 * @param node Node : the Node
 * @throws Exception : if error condition occurs
 */
public static String buildNodeString(Node node) throws Exception {
 Document document = node.getOwnerDocument();
 DOMImplementationLS domImplLS = (DOMImplementationLS) document
     .getImplementation();
 LSSerializer LSS = domImplLS.createLSSerializer();
 LSS.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
 LSS.getDomConfig().setParameter("discard-default-content", Boolean.FALSE);
 LSS.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
 return LSS.writeToString(node);
}
 
开发者ID:mqsysadmin,项目名称:dpdirect,代码行数:17,代码来源:DocumentHelper.java

示例7: testHasFeature

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Test(dataProvider = "doc")
public void testHasFeature(Document doc) {
    DOMImplementation di = doc.getImplementation();

    //return false if feasure == null
    Assert.assertFalse(di.hasFeature(null, null));

    //A feature is supported without specifying version
    Assert.assertTrue(di.hasFeature("ElementTraversal", null));
    Assert.assertTrue(di.hasFeature("ElementTraversal", ""));

    //ElementTraversal Version 1.0 is supported
    Assert.assertTrue(di.hasFeature("ElementTraversal", "1.0"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ElementTraversal.java

示例8: getNotifications

import org.w3c.dom.Document; //导入方法依赖的package包/类
private void getNotifications(Integer userId, HttpServletRequest request, HttpServletResponse response)
    throws IOException {
Document doc = NotificationServlet.docBuilder.newDocument();
Element notificationsElement = doc.createElement("Notifications");
doc.appendChild(notificationsElement);

Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, true);
Integer limit = WebUtil.readIntParam(request, "limit", true);
Integer offset = WebUtil.readIntParam(request, "offset", true);
Boolean pendingOnly = WebUtil.readBooleanParam(request, "pendingOnly", true);

List<Subscription> subscriptions = NotificationServlet.eventNotificationService
	.getNotificationSubscriptions(lessonId, userId, pendingOnly, limit, offset);
for (Subscription subscription : subscriptions) {
    Element notificationElement = doc.createElement("Notification");

    notificationElement.setAttribute("id", subscription.getUid().toString());

    Boolean pending = !DeliveryMethodNotification.LAST_OPERATION_SEEN
	    .equals(subscription.getLastOperationMessage());
    notificationElement.setAttribute("pending", pending.toString());

    Long notificationLessonId = subscription.getEvent().getEventSessionId();
    if (notificationLessonId != null) {
	notificationElement.setAttribute("lessonId", notificationLessonId.toString());
    }

    String message = subscription.getEvent().getMessage();
    Matcher matcher = NotificationServlet.anchorPattern.matcher(message);
    if (matcher.find()) {
	String href = StringEscapeUtils.escapeXml(matcher.group(2));
	notificationElement.setAttribute("href", href);
	message = matcher.group(3);
    }
    notificationElement.appendChild(doc.createCDATASection(message));

    notificationsElement.appendChild(notificationElement);
}

response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8");

DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
LSSerializer lsSerializer = domImplementation.createLSSerializer();
LSOutput lsOutput = domImplementation.createLSOutput();
lsOutput.setEncoding("UTF-8");
lsOutput.setByteStream(response.getOutputStream());
lsSerializer.write(doc, lsOutput);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:NotificationServlet.java

示例9: testDOMErrorHandler

import org.w3c.dom.Document; //导入方法依赖的package包/类
@Test
public void testDOMErrorHandler() {

    final String XML_DOCUMENT = "<?xml version=\"1.0\"?>" + "<hello>" + "world" + "</hello>";

    StringReader stringReader = new StringReader(XML_DOCUMENT);
    InputSource inputSource = new InputSource(stringReader);
    Document doc = null;
    try {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        // LSSerializer defaults to Namespace processing
        // so parsing must also
        documentBuilderFactory.setNamespaceAware(true);
        DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder();
        doc = parser.parse(inputSource);

    } catch (Throwable e) {
        e.printStackTrace();
        Assert.fail(e.toString());
    }

    DOMImplementation impl = doc.getImplementation();
    DOMImplementationLS implLS = (DOMImplementationLS) impl.getFeature("LS", "3.0");
    LSSerializer writer = implLS.createLSSerializer();

    System.out.println("Serializer is: " + implLS.getClass().getName() + " " + implLS);

    DOMErrorHandlerImpl eh = new DOMErrorHandlerImpl();
    writer.getDomConfig().setParameter("error-handler", eh);

    boolean serialized = false;
    try {
        serialized = writer.write(doc, new Output());

        // unexpected success
        Assert.fail("Serialized without raising an LSException due to " + "'no-output-specified'.");
    } catch (LSException lsException) {
        // expected exception
        System.out.println("Expected LSException: " + lsException.toString());
        // continue processing
    }

    Assert.assertFalse(serialized, "Expected writer.write(doc, new Output()) == false");

    Assert.assertTrue(eh.NoOutputSpecifiedErrorReceived, "'no-output-specified' error was expected");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:LSSerializerTest.java


注:本文中的org.w3c.dom.Document.getImplementation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。