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


Java DOMSource.getNode方法代码示例

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


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

示例1: SAXImpl

import javax.xml.transform.dom.DOMSource; //导入方法依赖的package包/类
/**
 * Construct a SAXImpl object using the given block size.
 */
public SAXImpl(XSLTCDTMManager mgr, Source source,
               int dtmIdentity, DTMWSFilter whiteSpaceFilter,
               XMLStringFactory xstringfactory,
               boolean doIndexing, int blocksize,
               boolean buildIdIndex,
               boolean newNameTable)
{
    super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
        doIndexing, blocksize, false, buildIdIndex, newNameTable);

    _dtmManager = mgr;
    _size = blocksize;

    // Use a smaller size for the space stack if the blocksize is small
    _xmlSpaceStack = new int[blocksize <= 64 ? 4 : 64];

    /* From DOMBuilder */
    _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE;

    // If the input source is DOMSource, set the _document field and
    // create the node2Ids table.
    if (source instanceof DOMSource) {
        _hasDOMSource = true;
        DOMSource domsrc = (DOMSource)source;
        Node node = domsrc.getNode();
        if (node instanceof Document) {
            _document = (Document)node;
        }
        else {
            _document = node.getOwnerDocument();
        }
        _node2Ids = new Hashtable();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:SAXImpl.java

示例2: setupDOMResultHandler

import javax.xml.transform.dom.DOMSource; //导入方法依赖的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:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:DOMValidatorHelper.java

示例3: SAXImpl

import javax.xml.transform.dom.DOMSource; //导入方法依赖的package包/类
/**
 * Construct a SAXImpl object using the given block size.
 */
public SAXImpl(XSLTCDTMManager mgr, Source source,
               int dtmIdentity, DTMWSFilter whiteSpaceFilter,
               XMLStringFactory xstringfactory,
               boolean doIndexing, int blocksize,
               boolean buildIdIndex,
               boolean newNameTable)
{
    super(mgr, source, dtmIdentity, whiteSpaceFilter, xstringfactory,
        doIndexing, blocksize, false, buildIdIndex, newNameTable);

    _dtmManager = mgr;
    _size = blocksize;

    // Use a smaller size for the space stack if the blocksize is small
    _xmlSpaceStack = new int[blocksize <= 64 ? 4 : 64];

    /* From DOMBuilder */
    _xmlSpaceStack[0] = DTMDefaultBase.ROOTNODE;

    // If the input source is DOMSource, set the _document field and
    // create the node2Ids table.
    if (source instanceof DOMSource) {
        _hasDOMSource = true;
        DOMSource domsrc = (DOMSource)source;
        Node node = domsrc.getNode();
        if (node instanceof Document) {
            _document = (Document)node;
        }
        else {
            _document = node.getOwnerDocument();
        }
        _node2Ids = new HashMap<>();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:SAXImpl.java

示例4: testSOAPEnvelope1

import javax.xml.transform.dom.DOMSource; //导入方法依赖的package包/类
@Test
public void testSOAPEnvelope1() throws Exception {
    setup();

    File f = new File(this.getClass().getResource(INPUT_FILE1).getFile());
    System.out.println("***********" + f.getName() + "***********");
    DOMSource src = makeDomSource(f);
    Node node = src.getNode();
    XMLStreamWriter writer = staxOut.createXMLStreamWriter(new PrintStream(System.out));
    DOMUtil.serializeNode((Element) node.getFirstChild(), writer);
    writer.close();
    assert (true);
    System.out.println("*****************************************");

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:DomUtilTest.java

示例5: getTargetNamespace

import javax.xml.transform.dom.DOMSource; //导入方法依赖的package包/类
private String getTargetNamespace(DOMSource src) {
    Element elem = (Element)src.getNode();
    return elem.getAttribute("targetNamespace");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:AbstractSchemaValidationTube.java

示例6: DOM2DTM

import javax.xml.transform.dom.DOMSource; //导入方法依赖的package包/类
/**
 * Construct a DOM2DTM object from a DOM node.
 *
 * @param mgr The DTMManager who owns this DTM.
 * @param domSource the DOM source that this DTM will wrap.
 * @param dtmIdentity The DTM identity ID for this DTM.
 * @param whiteSpaceFilter The white space filter for this DTM, which may
 *                         be null.
 * @param xstringfactory XMLString factory for creating character content.
 * @param doIndexing true if the caller considers it worth it to use
 *                   indexing schemes.
 */
public DOM2DTM(DTMManager mgr, DOMSource domSource,
               int dtmIdentity, DTMWSFilter whiteSpaceFilter,
               XMLStringFactory xstringfactory,
               boolean doIndexing)
{
  super(mgr, domSource, dtmIdentity, whiteSpaceFilter,
        xstringfactory, doIndexing);

  // Initialize DOM navigation
  m_pos=m_root = domSource.getNode();
  // Initialize DTM navigation
  m_last_parent=m_last_kid=NULL;
  m_last_kid=addNode(m_root, m_last_parent,m_last_kid, NULL);

  // Apparently the domSource root may not actually be the
  // Document node. If it's an Element node, we need to immediately
  // add its attributes. Adapted from nextNode().
  // %REVIEW% Move this logic into addNode and recurse? Cleaner!
  //
  // (If it's an EntityReference node, we're probably scrod. For now
  // I'm just hoping nobody is ever quite that foolish... %REVIEW%)
              //
              // %ISSUE% What about inherited namespaces in this case?
              // Do we need to special-case initialize them into the DTM model?
  if(ELEMENT_NODE == m_root.getNodeType())
  {
    NamedNodeMap attrs=m_root.getAttributes();
    int attrsize=(attrs==null) ? 0 : attrs.getLength();
    if(attrsize>0)
    {
      int attrIndex=NULL; // start with no previous sib
      for(int i=0;i<attrsize;++i)
      {
        // No need to force nodetype in this case;
        // addNode() will take care of switching it from
        // Attr to Namespace if necessary.
        attrIndex=addNode(attrs.item(i),0,attrIndex,NULL);
        m_firstch.setElementAt(DTM.NULL,attrIndex);
      }
      // Terminate list of attrs, and make sure they aren't
      // considered children of the element
      m_nextsib.setElementAt(DTM.NULL,attrIndex);

      // IMPORTANT: This does NOT change m_last_parent or m_last_kid!
    } // if attrs exist
  } //if(ELEMENT_NODE)

  // Initialize DTM-completed status
  m_nodesAreProcessed = false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:DOM2DTM.java


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