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


Java DOMResult.getNode方法代碼示例

本文整理匯總了Java中javax.xml.transform.dom.DOMResult.getNode方法的典型用法代碼示例。如果您正苦於以下問題:Java DOMResult.getNode方法的具體用法?Java DOMResult.getNode怎麽用?Java DOMResult.getNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.transform.dom.DOMResult的用法示例。


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

示例1: cloneDoc

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public Document cloneDoc ( final Document doc ) throws TransformerException
{
    final Transformer tx = this.tf.newTransformer ();
    final DOMSource source = new DOMSource ( doc );
    final DOMResult result = new DOMResult ();
    tx.transform ( source, result );
    return (Document)result.getNode ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:9,代碼來源:SignatureRequestBuilder.java

示例2: writeTo

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public void writeTo(SOAPMessage saaj) throws SOAPException {
    try {
        // TODO what about in-scope namespaces
        // Not very efficient consider implementing a stream buffer
        // processor that produces a DOM node from the buffer.
        TransformerFactory tf = XmlUtil.newTransformerFactory();
        Transformer t = tf.newTransformer();
        XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
        DOMResult result = new DOMResult();
        t.transform(source, result);
        Node d = result.getNode();
        if(d.getNodeType() == Node.DOCUMENT_NODE)
            d = d.getFirstChild();
        SOAPHeader header = saaj.getSOAPHeader();
        if(header == null)
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        Node node = header.getOwnerDocument().importNode(d, true);
        header.appendChild(node);
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:StreamHeader.java

示例3: setDOMResult

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public void setDOMResult(DOMResult result) {
    fCurrentNode = null;
    fFragmentRoot = null;
    fIgnoreChars = false;
    fTargetChildren.clear();
    if (result != null) {
        fTarget = result.getNode();
        fNextSibling = result.getNextSibling();
        fDocument = (fTarget.getNodeType() == Node.DOCUMENT_NODE) ? (Document) fTarget : fTarget.getOwnerDocument();
        fDocumentImpl = (fDocument instanceof CoreDocumentImpl) ? (CoreDocumentImpl) fDocument : null;
        fStorePSVI = (fDocument instanceof PSVIDocumentImpl);
        return;
    }
    fTarget = null;
    fNextSibling = null;
    fDocument = null;
    fDocumentImpl = null;
    fStorePSVI = false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:DOMResultBuilder.java

示例4: DomSerializer

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:DomSerializer.java

示例5: test

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
@Test
public void test() throws Exception {
    SAXParserFactory fac = SAXParserFactory.newInstance();
    fac.setNamespaceAware(true);
    SAXParser saxParser = fac.newSAXParser();

    StreamSource sr = new StreamSource(this.getClass().getResourceAsStream("SAX2DOMTest.xml"));
    InputSource is = SAXSource.sourceToInputSource(sr);
    RejectDoctypeSaxFilter rf = new RejectDoctypeSaxFilter(saxParser);
    SAXSource src = new SAXSource(rf, is);
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    DOMResult result = new DOMResult();
    transformer.transform(src, result);

    Document doc = (Document) result.getNode();
    System.out.println("Name" + doc.getDocumentElement().getLocalName());

    String id = "XWSSGID-11605791027261938254268";
    Element selement = doc.getElementById(id);
    if (selement == null) {
        System.out.println("getElementById returned null");
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:SAX2DOMTest.java

示例6: XMLDOMWriterImpl

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
/**
 * Creates a new instance of XMLDOMwriterImpl
 * @param result DOMResult object @javax.xml.transform.dom.DOMResult
 */
public XMLDOMWriterImpl(DOMResult result) {

    node = result.getNode();
    if( node.getNodeType() == Node.DOCUMENT_NODE){
        ownerDoc = (Document)node;
        currentNode = ownerDoc;
    }else{
        ownerDoc = node.getOwnerDocument();
        currentNode = node;
    }
    getDLThreeMethods();
    stringBuffer = new StringBuffer();
    needContextPop = new boolean[resizeValue];
    namespaceContext = new NamespaceSupport();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:20,代碼來源:XMLDOMWriterImpl.java

示例7: writeTo

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public void writeTo(SOAPMessage saaj) throws SOAPException {
    try {
        // TODO what about in-scope namespaces
        // Not very efficient consider implementing a stream buffer
        // processor that produces a DOM node from the buffer.
        TransformerFactory tf = XmlUtil.newTransformerFactory(true);
        Transformer t = tf.newTransformer();
        XMLStreamBufferSource source = new XMLStreamBufferSource(_mark);
        DOMResult result = new DOMResult();
        t.transform(source, result);
        Node d = result.getNode();
        if(d.getNodeType() == Node.DOCUMENT_NODE)
            d = d.getFirstChild();
        SOAPHeader header = saaj.getSOAPHeader();
        if(header == null)
            header = saaj.getSOAPPart().getEnvelope().addHeader();
        Node node = header.getOwnerDocument().importNode(d, true);
        header.appendChild(node);
    } catch (Exception e) {
        throw new SOAPException(e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:23,代碼來源:StreamHeader.java

示例8: createDOM

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
private Document createDOM(SDDocument doc) {
    // Get infoset
    ByteArrayBuffer bab = new ByteArrayBuffer();
    try {
        doc.writeTo(null, resolver, bab);
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }

    // Convert infoset to DOM
    Transformer trans = XmlUtil.newTransformer();
    Source source = new StreamSource(bab.newInputStream(), null); //doc.getURL().toExternalForm());
    DOMResult result = new DOMResult();
    try {
        trans.transform(source, result);
    } catch(TransformerException te) {
        throw new WebServiceException(te);
    }
    return (Document)result.getNode();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:AbstractSchemaValidationTube.java

示例9: getElement

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public Element getElement(DOMResult r) {
    // JAXP spec is ambiguous about what really happens in this case,
    // so work defensively
    Node n = r.getNode();
    if( n instanceof Document ) {
        return ((Document)n).getDocumentElement();
    }
    if( n instanceof Element )
        return (Element)n;
    if( n instanceof DocumentFragment )
        return (Element)n.getChildNodes().item(0);

    // if the result object contains something strange,
    // it is not a user problem, but it is a JAXB provider's problem.
    // That's why we throw a runtime exception.
    throw new IllegalStateException(n.toString());
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:18,代碼來源:W3CDomHandler.java

示例10: test1

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
@Test
public void test1() throws Exception {

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder parser = dbf.newDocumentBuilder();
    Document dom = parser.parse(Bug5072946.class.getResourceAsStream("Bug5072946.xml"));

    SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema s = sf.newSchema(Bug5072946.class.getResource("Bug5072946.xsd"));
    Validator v = s.newValidator();

    DOMResult r = new DOMResult();
    // r.setNode(dbf.newDocumentBuilder().newDocument());
    v.validate(new DOMSource(dom), r);

    Node node = r.getNode();
    Assert.assertNotNull(node);
    Node fc = node.getFirstChild();
    Assert.assertTrue(fc instanceof Element);
    Element e = (Element) fc;

    Assert.assertEquals("value", e.getAttribute("foo"));
}
 
開發者ID:campolake,項目名稱:openjdk9,代碼行數:25,代碼來源:Bug5072946.java

示例11: resolve

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public XNodeSet resolve(ExpressionContext context, String uri, String sStatic) throws TransformerException {
    boolean bStatic = "true".equals(sStatic) || includesPerApplication.containsKey(uri);
    Map<String, Node> includes = bStatic ? includesPerApplication : includesPerTransformation;

    LOGGER.debug("Including {} static={} cached={}", uri, bStatic, includes.containsKey(uri));

    Node node = includes.get(uri);
    if (node == null) {
        Source source = MCRURIResolver.instance().resolve(uri, null);
        if (source instanceof DOMSource)
            node = ((DOMSource) source).getNode();
        else {
            DOMResult result = new DOMResult();
            TransformerFactory.newInstance().newTransformer().transform(source, result);
            node = result.getNode();
        }
        includes.put(uri, node);
    }

    NodeSet nodeSet = new NodeSet();
    nodeSet.addNode(node);
    return new XNodeSetForDOM((NodeList) nodeSet, context.getXPathContext());
}
 
開發者ID:MyCoRe-Org,項目名稱:mycore,代碼行數:24,代碼來源:MCRIncludeHandler.java

示例12: getHtmlAsXml

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
@Override
public XmlScriptType getHtmlAsXml()
{
	try
	{
		XMLReader htmlParser = new Parser();
		htmlParser.setFeature(Parser.namespacesFeature, false);
		htmlParser.setFeature(Parser.namespacePrefixesFeature, false);

		Transformer transformer = TransformerFactory.newInstance().newTransformer();

		DOMResult result = new DOMResult();
		transformer.transform(new SAXSource(htmlParser, new InputSource(new StringReader(getAsText()))),
			result);

		Node node = result.getNode();
		if( node.getNodeType() == Node.DOCUMENT_NODE )
		{
			node = node.getFirstChild();
		}
		return new PropBagWrapper(new PropBagEx(node));
	}
	catch( Exception ex )
	{
		throw new RuntimeException("Response received from external URL could not be tidied into XML", ex);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:28,代碼來源:UtilsScriptWrapper.java

示例13: setupDOMResultHandler

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
/**
 * Sets up handler for <code>DOMResult</code>.
 */
private void setupDOMResultHandler(DOMSource source, DOMResult result) throws SAXException {
    // If there's no DOMResult, unset the validator handler
    if (result == null) {
        fDOMValidatorHandler = null;
        fSchemaValidator.setDocumentHandler(null);
        return;
    }
    final Node nodeResult = result.getNode();
    // If the source node and result node are the same use the DOMResultAugmentor.
    // Otherwise use the DOMResultBuilder.
    if (source.getNode() == nodeResult) {
        fDOMValidatorHandler = fDOMResultAugmentor;
        fDOMResultAugmentor.setDOMResult(result);
        fSchemaValidator.setDocumentHandler(fDOMResultAugmentor);
        return;
    }
    if (result.getNode() == null) {
        try {
            DocumentBuilderFactory factory = fComponentManager.getFeature(Constants.ORACLE_FEATURE_SERVICE_MECHANISM) ?
                                DocumentBuilderFactory.newInstance() : new DocumentBuilderFactoryImpl();
            factory.setNamespaceAware(true);
            DocumentBuilder builder = factory.newDocumentBuilder();
            result.setNode(builder.newDocument());
        }
        catch (ParserConfigurationException e) {
            throw new SAXException(e);
        }
    }
    fDOMValidatorHandler = fDOMResultBuilder;
    fDOMResultBuilder.setDOMResult(result);
    fSchemaValidator.setDocumentHandler(fDOMResultBuilder);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:36,代碼來源:DOMValidatorHelper.java

示例14: getQueryAsDOM

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
/**
 * Slow means of constructing query - parses stylesheet from input stream
 */
public static Document getQueryAsDOM(Properties formProperties, InputStream xslIs)
    throws SAXException, IOException, ParserConfigurationException, TransformerException {
  DOMResult result = new DOMResult();
  transformCriteria(formProperties, xslIs, result);
  return (Document) result.getNode();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:QueryTemplateManager.java

示例15: getPayload

import javax.xml.transform.dom.DOMResult; //導入方法依賴的package包/類
public Source getPayload() {
    assert (!(payloadSrc instanceof DOMSource));
    try {
        Transformer transformer = XmlUtil.newTransformer();
        DOMResult domResult = new DOMResult();
        transformer.transform(payloadSrc, domResult);
        DOMSource dom = new DOMSource(domResult.getNode());
        lm = new DOMLogicalMessageImpl((DOMSource) dom);
        payloadSrc = null;
        return dom;
    } catch (TransformerException te) {
        throw new WebServiceException(te);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:LogicalMessageImpl.java


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