當前位置: 首頁>>代碼示例>>Java>>正文


Java DOMImplementationLS類代碼示例

本文整理匯總了Java中org.w3c.dom.ls.DOMImplementationLS的典型用法代碼示例。如果您正苦於以下問題:Java DOMImplementationLS類的具體用法?Java DOMImplementationLS怎麽用?Java DOMImplementationLS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DOMImplementationLS類屬於org.w3c.dom.ls包,在下文中一共展示了DOMImplementationLS類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateXmlResult

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的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

示例2: getLSSerializer

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Obtain a the DOM, level 3, Load/Save serializer {@link LSSerializer} instance from the
 * given {@link DOMImplementationLS} instance.
 * 
 * <p>
 * The serializer instance will be configured with the parameters passed as the <code>serializerParams</code>
 * argument. It will also be configured with an {@link LSSerializerFilter} that shows all nodes to the filter, 
 * and accepts all nodes shown.
 * </p>
 * 
 * @param domImplLS the DOM Level 3 Load/Save implementation to use
 * @param serializerParams parameters to pass to the {@link DOMConfiguration} of the serializer
 *         instance, obtained via {@link LSSerializer#getDomConfig()}. May be null.
 *         
 * @return a new LSSerializer instance
 */
public static LSSerializer getLSSerializer(DOMImplementationLS domImplLS, Map<String, Object> serializerParams) {
    LSSerializer serializer = domImplLS.createLSSerializer();
    
    serializer.setFilter(new LSSerializerFilter() {

        public short acceptNode(Node arg0) {
            return FILTER_ACCEPT;
        }

        public int getWhatToShow() {
            return SHOW_ALL;
        }
    });
    
    
    if (serializerParams != null) {
        DOMConfiguration serializerDOMConfig = serializer.getDomConfig();
        for (String key : serializerParams.keySet()) {
            serializerDOMConfig.setParameter(key, serializerParams.get(key));
        }
    }
    
    return serializer;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:41,代碼來源:XMLHelper.java

示例3: main

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的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: testCreateNewItem2Sell

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Check for DOMErrorHandler handling DOMError. Before fix of bug 4890927
 * DOMConfiguration.setParameter("well-formed",true) throws an exception.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testCreateNewItem2Sell() throws Exception {
    String xmlFile = XML_DIR + "novelsInvalid.xml";

    Document document = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(xmlFile);

    document.getDomConfig().setParameter("well-formed", true);

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    MyDOMOutput domOutput = new MyDOMOutput();
    domOutput.setByteStream(System.out);
    LSSerializer writer = impl.createLSSerializer();
    writer.write(document, domOutput);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:AuctionController.java

示例5: testCreateNewItem2SellRetry

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Check for DOMErrorHandler handling DOMError. Before fix of bug 4896132
 * test throws DOM Level 1 node error.
 *
 * @throws Exception If any errors occur.
 */
@Test
public void testCreateNewItem2SellRetry() throws Exception  {
    String xmlFile = XML_DIR + "accountInfo.xml";

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document document = dbf.newDocumentBuilder().parse(xmlFile);

    DOMConfiguration domConfig = document.getDomConfig();
    MyDOMErrorHandler errHandler = new MyDOMErrorHandler();
    domConfig.setParameter("error-handler", errHandler);

    DOMImplementationLS impl =
         (DOMImplementationLS) DOMImplementationRegistry.newInstance()
                 .getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();
    MyDOMOutput domoutput = new MyDOMOutput();

    domoutput.setByteStream(System.out);
    writer.write(document, domoutput);

    document.normalizeDocument();
    writer.write(document, domoutput);
    assertFalse(errHandler.isError());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:32,代碼來源:AuctionController.java

示例6: testLSInputParsingByteStream

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
@Test
public void testLSInputParsingByteStream() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSInput src = impl.createLSInput();

    try (InputStream is = new FileInputStream(ASTROCAT)) {
        src.setByteStream(is);
        assertNotNull(src.getByteStream());
        // set certified accessor methods
        boolean origCertified = src.getCertifiedText();
        src.setCertifiedText(true);
        assertTrue(src.getCertifiedText());
        src.setCertifiedText(origCertified); // set back to orig

        src.setSystemId(filenameToURL(ASTROCAT));

        Document doc = domParser.parse(src);
        Element result = doc.getDocumentElement();
        assertEquals(result.getTagName(), "stardb");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:DocumentLSTest.java

示例7: testLSInputParsingString

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
@Test
public void testLSInputParsingString() throws Exception {
    DOMImplementationLS impl = (DOMImplementationLS) getDocumentBuilder().getDOMImplementation();
    String xml = "<?xml version='1.0'?><test>runDocumentLS_Q6</test>";

    LSParser domParser = impl.createLSParser(MODE_SYNCHRONOUS, null);
    LSSerializer domSerializer = impl.createLSSerializer();
    // turn off xml decl in serialized string for comparison
    domSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
    LSInput src = impl.createLSInput();
    src.setStringData(xml);
    assertEquals(src.getStringData(), xml);

    Document doc = domParser.parse(src);
    String result = domSerializer.writeToString(doc);

    assertEquals(result, "<test>runDocumentLS_Q6</test>");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:DocumentLSTest.java

示例8: testCreateNewItem2Sell

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Check for DOMErrorHandler handling DOMError. Before fix of bug 4890927
 * DOMConfiguration.setParameter("well-formed",true) throws an exception.
 *
 * @throws Exception If any errors occur.
 */
@Test(groups = {"readLocalFiles"})
public void testCreateNewItem2Sell() throws Exception {
    String xmlFile = XML_DIR + "novelsInvalid.xml";

    Document document = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(xmlFile);

    document.getDomConfig().setParameter("well-formed", true);

    DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
    DOMImplementationLS impl = (DOMImplementationLS) registry.getDOMImplementation("LS");
    MyDOMOutput domOutput = new MyDOMOutput();
    domOutput.setByteStream(System.out);
    LSSerializer writer = impl.createLSSerializer();
    writer.write(document, domOutput);
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:23,代碼來源:AuctionController.java

示例9: testCreateNewItem2SellRetry

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Check for DOMErrorHandler handling DOMError. Before fix of bug 4896132
 * test throws DOM Level 1 node error.
 *
 * @throws Exception If any errors occur.
 */
@Test(groups = {"readLocalFiles"})
public void testCreateNewItem2SellRetry() throws Exception  {
    String xmlFile = XML_DIR + "accountInfo.xml";

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    Document document = dbf.newDocumentBuilder().parse(xmlFile);

    DOMConfiguration domConfig = document.getDomConfig();
    MyDOMErrorHandler errHandler = new MyDOMErrorHandler();
    domConfig.setParameter("error-handler", errHandler);

    DOMImplementationLS impl =
         (DOMImplementationLS) DOMImplementationRegistry.newInstance()
                 .getDOMImplementation("LS");
    LSSerializer writer = impl.createLSSerializer();
    MyDOMOutput domoutput = new MyDOMOutput();

    domoutput.setByteStream(System.out);
    writer.write(document, domoutput);

    document.normalizeDocument();
    writer.write(document, domoutput);
    assertFalse(errHandler.isError());
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:32,代碼來源:AuctionController.java

示例10: marshall

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * `
 * Serialize XML objects
 *
 * @param xmlObject : XACML or SAML objects to be serialized
 * @return serialized XACML or SAML objects
 * @throws EntitlementException
 */
private String marshall(XMLObject xmlObject) throws EntitlementException {

    try {
        doBootstrap();
        System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
                "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");

        MarshallerFactory marshallerFactory = org.opensaml.xml.Configuration.getMarshallerFactory();
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = marshaller.marshall(xmlObject);

        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS impl =
                (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = impl.createLSSerializer();
        LSOutput output = impl.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return byteArrayOutputStream.toString();
    } catch (Exception e) {
        log.error("Error Serializing the SAML Response");
        throw new EntitlementException("Error Serializing the SAML Response", e);
    }
}
 
開發者ID:wso2,項目名稱:carbon-identity-framework,代碼行數:34,代碼來源:WSXACMLMessageReceiver.java

示例11: saveConfiguration

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Saves the process configuration.
 */
private void saveConfiguration(Document docXMLConfig) {
  String fileToSaveConf = properties.getSaveRemoteConfig();
  if (fileToSaveConf.length() > 0 && docXMLConfig != null) {
    log.info("saveConfiguration - saving the process configuration XML in a file " + fileToSaveConf + " due to user request");

    File file = new File(fileToSaveConf);
    if (file.isDirectory() || !fileToSaveConf.endsWith(".xml")) {
      throw new RuntimeException("Path to which to save remote config must end with '.xml'");
    }

    try {
      DOMImplementationLS domImplementation = (DOMImplementationLS) docXMLConfig.getImplementation();
      LSSerializer lsSerializer = domImplementation.createLSSerializer();
      lsSerializer.writeToURI(docXMLConfig, file.toURI().toURL().toString());
    } catch (java.io.IOException ex) {
      log.error("saveConfiguration - Could not save the configuration to the file " + fileToSaveConf, ex);
    }
  }
}
 
開發者ID:c2mon,項目名稱:c2mon,代碼行數:23,代碼來源:ConfigurationController.java

示例12: marshall

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Serializes the specified SAML 2.0 based XML content representation to its corresponding actual XML syntax
 * representation.
 *
 * @param xmlObject the SAML 2.0 based XML content object
 * @return a {@link String} representation of the actual XML representation of the SAML 2.0 based XML content
 * representation
 * @throws SSOException if an error occurs during the marshalling process
 */
public static String marshall(XMLObject xmlObject) throws SSOException {
    try {
        Marshaller marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(xmlObject);
        Element element = null;
        if (marshaller != null) {
            element = marshaller.marshall(xmlObject);
        }
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
        DOMImplementationLS implementation = (DOMImplementationLS) registry.getDOMImplementation("LS");
        LSSerializer writer = implementation.createLSSerializer();
        LSOutput output = implementation.createLSOutput();
        output.setByteStream(byteArrayOutputStream);
        writer.write(element, output);
        return new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);
    } catch (ClassNotFoundException | InstantiationException | MarshallingException | IllegalAccessException e) {
        throw new SSOException("Error in marshalling SAML 2.0 Assertion", e);
    }
}
 
開發者ID:wso2-extensions,項目名稱:tomcat-extension-samlsso,代碼行數:29,代碼來源:SSOUtils.java

示例13: toXml

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
public static String toXml(Document domDoc) throws TransformerException {
    DOMImplementation domImplementation = domDoc.getImplementation();
    if (domImplementation.hasFeature("LS", "3.0") && domImplementation.hasFeature("Core", "2.0")) {
        DOMImplementationLS domImplementationLS = (DOMImplementationLS) domImplementation.getFeature("LS", "3.0");
        LSSerializer lsSerializer = domImplementationLS.createLSSerializer();
        DOMConfiguration domConfiguration = lsSerializer.getDomConfig();
        if (domConfiguration.canSetParameter("xml-declaration", Boolean.TRUE))
            lsSerializer.getDomConfig().setParameter("xml-declaration", Boolean.FALSE);
        if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
            lsSerializer.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
            LSOutput lsOutput = domImplementationLS.createLSOutput();
            lsOutput.setEncoding("UTF-8");
            StringWriter stringWriter = new StringWriter();
            lsOutput.setCharacterStream(stringWriter);
            lsSerializer.write(domDoc, lsOutput);
            return stringWriter.toString();
        }
    }
    return toXml((Node)domDoc);
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:21,代碼來源:DomHelper.java

示例14: createMetadataFile

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
/**
 * Creates the metadata file for the file that was created by the wizard.
 *
 * @param targetFolder The folder on which the metadata file will be created.
 */
private void createMetadataFile(FileObject targetFolder) {
    try {
        Document newXmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element rootElement = newXmlDocument.createElementNS(SALESFORCE_METADATA_NAMESPACE, getMetadataName());
        Element childElement;
        for (Map.Entry<String, String> node : getMetadataParameters().entrySet()) {
            childElement = newXmlDocument.createElement(node.getKey());
            childElement.setTextContent(node.getValue());
            rootElement.appendChild(childElement);
        }
        FileObject createdData = targetFolder.createData(getMetadataFileName());
        DOMImplementationLS domImplementation = (DOMImplementationLS) newXmlDocument.getImplementation();
        LSSerializer serializer = domImplementation.createLSSerializer();
        serializer.writeToURI(rootElement, createdData.toURI().toString());
    } catch (ParserConfigurationException | IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
開發者ID:fundacionjala,項目名稱:oblivion-netbeans-plugin,代碼行數:24,代碼來源:AbstractFileTypeWizardIterator.java

示例15: DomDocumentBuilderFactory

import org.w3c.dom.ls.DOMImplementationLS; //導入依賴的package包/類
public DomDocumentBuilderFactory()
{
  try
    {
      DOMImplementationRegistry reg =
        DOMImplementationRegistry.newInstance();
      impl = reg.getDOMImplementation("LS 3.0");
      if (impl == null)
        {
          throw new FactoryConfigurationError("no LS implementations found");
        }
      ls = (DOMImplementationLS) impl;
    }
  catch (Exception e)
    {
      throw new FactoryConfigurationError(e);
    }
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:19,代碼來源:DomDocumentBuilderFactory.java


注:本文中的org.w3c.dom.ls.DOMImplementationLS類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。