当前位置: 首页>>代码示例>>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;未经允许,请勿转载。