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


Java DTM.getDocument方法代码示例

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


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

示例1: rtf

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * Cast result object to a result tree fragment.
 *
 * @param support XPath context to use for the conversion
 *
 * @return the objec as a result tree fragment.
 */
public int rtf(XPathContext support)
{

  int result = rtf();

  if (DTM.NULL == result)
  {
    DTM frag = support.createDocumentFragment();

    // %OPT%
    frag.appendTextChild(str());

    result = frag.getDocument();
  }

  return result;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:25,代码来源:XObject.java

示例2: parseToNode

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * Try to create a DOM source tree from the input source.
 *
 * @param source The Source object that identifies the source node.
 * @param locator The location of the caller, for diagnostic purposes.
 *
 * @return non-null reference to node identified by the source argument.
 *
 * @throws TransformerException if the source argument can not be resolved 
 *         to a source node.
 */
public int parseToNode(Source source, SourceLocator locator, XPathContext xctxt)
        throws TransformerException
{

  try
  {      
    Object xowner = xctxt.getOwnerObject();
    DTM dtm;
    if(null != xowner && xowner instanceof org.apache.xml.dtm.DTMWSFilter)
    {
      dtm = xctxt.getDTM(source, false, 
                        (org.apache.xml.dtm.DTMWSFilter)xowner, false, true);
    }
    else
    {
      dtm = xctxt.getDTM(source, false, null, false, true);
    }
    return dtm.getDocument();
  }
  catch (Exception e)
  {
    //e.printStackTrace();
    throw new TransformerException(e.getMessage(), locator, e);
  }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:38,代码来源:SourceTreeManager.java

示例3: execute

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * Execute the function.  The function must return
 * a valid object.
 * @param xctxt The current execution context.
 * @return A valid XObject.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException
{

  String name = m_arg0.execute(xctxt).str();
  int context = xctxt.getCurrentNode();
  DTM dtm = xctxt.getDTM(context);
  int doc = dtm.getDocument();
  
  String uri = dtm.getUnparsedEntityURI(name);

  return new XString(uri);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:FuncUnparsedEntityURI.java

示例4: execute

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * The here function returns a node-set containing the attribute or
 * processing instruction node or the parent element of the text node
 * that directly bears the XPath expression.  This expression results
 * in an error if the containing XPath expression does not appear in the
 * same XML document against which the XPath expression is being evaluated.
 *
 * @param xctxt
 * @return the xobject
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt) throws TransformerException {

    Node xpathOwnerNode = (Node) xctxt.getOwnerObject();

    if (xpathOwnerNode == null) {
        return null;
    }

    int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);

    int currentNode = xctxt.getCurrentNode();
    DTM dtm = xctxt.getDTM(currentNode);
    int docContext = dtm.getDocument();

    if (DTM.NULL == docContext) {
        error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
    }

    {
        // check whether currentNode and the node containing the XPath expression
        // are in the same document
        Document currentDoc =
            XMLUtils.getOwnerDocument(dtm.getNode(currentNode));
        Document xpathOwnerDoc = XMLUtils.getOwnerDocument(xpathOwnerNode);

        if (currentDoc != xpathOwnerDoc) {
            throw new TransformerException(I18n.translate("xpath.funcHere.documentsDiffer"));
        }
    }

    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
    NodeSetDTM nodeSet = nodes.mutableNodeset();

    {
        int hereNode = DTM.NULL;

        switch (dtm.getNodeType(xpathOwnerNodeDTM)) {

        case Node.ATTRIBUTE_NODE :
        case Node.PROCESSING_INSTRUCTION_NODE : {
            // returns a node-set containing the attribute /  processing instruction node
            hereNode = xpathOwnerNodeDTM;

            nodeSet.addNode(hereNode);

            break;
        }
        case Node.TEXT_NODE : {
            // returns a node-set containing the parent element of the
            // text node that directly bears the XPath expression
            hereNode = dtm.getParent(xpathOwnerNodeDTM);

            nodeSet.addNode(hereNode);

            break;
        }
        default :
            break;
        }
    }

    /** $todo$ Do I have to do this detach() call? */
    nodeSet.detach();

    return nodes;
}
 
开发者ID:Legostaev,项目名称:xmlsec-gost,代码行数:78,代码来源:FuncHere.java

示例5: transformToRTF

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
  * Given a stylesheet element, create a result tree fragment from it's
  * contents.
  * @param templateParent The template element that holds the fragment.
  * @param dtmFrag The DTM to write the RTF into
  * @return the NodeHandle for the root node of the resulting RTF.
  *
  * @throws TransformerException
  * @xsl.usage advanced
  */
 private int transformToRTF(ElemTemplateElement templateParent,DTM dtmFrag)
         throws TransformerException
 {

   XPathContext xctxt = m_xcontext;
   
   ContentHandler rtfHandler = dtmFrag.getContentHandler();

   // Obtain the ResultTreeFrag's root node.
   // NOTE: In SAX2RTFDTM, this value isn't available until after
   // the startDocument has been issued, so assignment has been moved
   // down a bit in the code.
   int resultFragment; // not yet reliably = dtmFrag.getDocument();

   // Save the current result tree handler.
   SerializationHandler savedRTreeHandler = this.m_serializationHandler;


   // And make a new handler for the RTF.
   ToSAXHandler h = new ToXMLSAXHandler();
   h.setContentHandler(rtfHandler);
   h.setTransformer(this);
   
   // Replace the old handler (which was already saved)
   m_serializationHandler = h;

   // use local variable for the current handler
   SerializationHandler rth = m_serializationHandler;

   try
   {
     rth.startDocument();
     
     // startDocument is "bottlenecked" in RTH. We need it acted upon immediately,
     // to set the DTM's state as in-progress, so that if the xsl:variable's body causes
     // further RTF activity we can keep that from bashing this DTM.
     rth.flushPending(); 

     try
     {

       // Do the transformation of the child elements.
       executeChildTemplates(templateParent, true);

       // Make sure everything is flushed!
       rth.flushPending();
       
       // Get the document ID. May not exist until the RTH has not only
       // received, but flushed, the startDocument, and may be invalid
       // again after the document has been closed (still debating that)
       // ... so waiting until just before the end seems simplest/safest. 
resultFragment = dtmFrag.getDocument();      
     }
     finally
     {
       rth.endDocument();
     }
   }
   catch (org.xml.sax.SAXException se)
   {
     throw new TransformerException(se);
   }
   finally
   {

     // Restore the previous result tree handler.
     this.m_serializationHandler = savedRTreeHandler;
   }

   return resultFragment;
 }
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:82,代码来源:TransformerImpl.java

示例6: rtf

import org.apache.xml.dtm.DTM; //导入方法依赖的package包/类
/**
 * Cast result object to a result tree fragment.
 *
 * @param support Xpath context to use for the conversion
 *
 * @return A document fragment with this string as a child node
 */
public int rtf(XPathContext support)
{

  DTM frag = support.createDocumentFragment();

  frag.appendTextChild(str());

  return frag.getDocument();
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:17,代码来源:XString.java


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