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


Java DTM.ELEMENT_NODE属性代码示例

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


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

示例1: shouldStripWhiteSpace

/**
 * Get information about whether or not an element should strip whitespace.
 * @see <a href="http://www.w3.org/TR/xslt#strip">strip in XSLT Specification</a>
 *
 * @param support The XPath runtime state.
 * @param targetElement Element to check
 *
 * @return true if the whitespace should be stripped.
 *
 * @throws TransformerException
 */
public boolean shouldStripWhiteSpace(
        XPathContext support, int targetElement) throws TransformerException
{
  if (null != m_whiteSpaceInfoList)
  {
    while(DTM.NULL != targetElement)
    {
      DTM dtm = support.getDTM(targetElement);
      WhiteSpaceInfo info = (WhiteSpaceInfo) m_whiteSpaceInfoList.getTemplate(support,
              targetElement, null, false, dtm);
      if(null != info)
        return info.getShouldStripSpace();
      
      int parent = dtm.getParent(targetElement);
      if(DTM.NULL != parent && DTM.ELEMENT_NODE == dtm.getNodeType(parent))
        targetElement = parent;
      else
        targetElement = DTM.NULL;
    }
  }
  return false;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:33,代码来源:StylesheetRoot.java

示例2: outputResultTreeFragment

/**
 * Given a result tree fragment, walk the tree and
 * output it to the SerializationHandler.
 *
 * @param obj Result tree fragment object
 * @param support XPath context for the result tree fragment
 *
 * @throws org.xml.sax.SAXException
 */
public static void outputResultTreeFragment(
    SerializationHandler handler,
    XObject obj,
    XPathContext support)
    throws org.xml.sax.SAXException
{

    int doc = obj.rtf();
    DTM dtm = support.getDTM(doc);

    if (null != dtm)
    {
        for (int n = dtm.getFirstChild(doc);
            DTM.NULL != n;
            n = dtm.getNextSibling(n))
        {
            handler.flushPending();

            // I think. . . . This used to have a (true) arg
            // to flush prefixes, will that cause problems ???
            if (dtm.getNodeType(n) == DTM.ELEMENT_NODE
                    && dtm.getNamespaceURI(n) == null)
                handler.startPrefixMapping("", "");
            dtm.dispatchToEvents(n, handler);
        }
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:36,代码来源:SerializerUtils.java

示例3: endNode

/**
 * End processing of given node 
 *
 *
 * @param node Node we just finished processing
 *
 * @throws org.xml.sax.SAXException
 */
protected void endNode(int node) throws org.xml.sax.SAXException
{
  super.endNode(node);
  if(DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
  {
    m_transformer.getXPathContext().popCurrentNode();
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:16,代码来源:TreeWalker2Result.java

示例4: getElementsByTagName

/**
 *
 * @param tagname
 *
 *
 * @see org.w3c.dom.Document
 */
public final NodeList getElementsByTagName(String tagname) 
{
     Vector listVector = new Vector();
     Node retNode = dtm.getNode(node);
     if (retNode != null) 
     {
       boolean isTagNameWildCard = "*".equals(tagname);
       if (DTM.ELEMENT_NODE == retNode.getNodeType()) 
       {
         NodeList nodeList = retNode.getChildNodes();
         for (int i = 0; i < nodeList.getLength(); i++) 
         {
           traverseChildren(listVector, nodeList.item(i), tagname,
                            isTagNameWildCard);
         }
       } else if (DTM.DOCUMENT_NODE == retNode.getNodeType()) {
         traverseChildren(listVector, dtm.getNode(node), tagname,
                          isTagNameWildCard);
       }
     }
     int size = listVector.size();
     NodeSet nodeSet = new NodeSet(size);
     for (int i = 0; i < size; i++) 
     {
       nodeSet.addNode((Node) listVector.elementAt(i));
     }
     return (NodeList) nodeSet;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:35,代码来源:DTMNodeProxy.java

示例5: if

/**
 * 
 * @param listVector
 * @param tempNode
 * @param tagname
 * @param isTagNameWildCard
 * 
 * 
 * Private method to be used for recursive iterations to obtain elements by tag name.
 */
private final void traverseChildren
(
  Vector listVector,
  Node tempNode,
  String tagname,
  boolean isTagNameWildCard) {
  if (tempNode == null) 
  {
    return;
  } 
  else
  { 
    if (tempNode.getNodeType() == DTM.ELEMENT_NODE
          && (isTagNameWildCard || tempNode.getNodeName().equals(tagname)))
    {
      listVector.add(tempNode);
    }
    if(tempNode.hasChildNodes())
    {
      NodeList nodeList = tempNode.getChildNodes();
      for (int i = 0; i < nodeList.getLength(); i++)
      {
        traverseChildren(listVector, nodeList.item(i), tagname,
                         isTagNameWildCard);
      }
    }
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:38,代码来源:DTMNodeProxy.java

示例6: getElementsByTagNameNS

/**
 *
 * @param namespaceURI
 * @param localName
 *
 *
 * @see org.w3c.dom.Document as of DOM Level 2
 */
public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
{
  Vector listVector = new Vector();
  Node retNode = dtm.getNode(node);
  if (retNode != null)
  {               
    boolean isNamespaceURIWildCard = "*".equals(namespaceURI);
    boolean isLocalNameWildCard    = "*".equals(localName);
    if (DTM.ELEMENT_NODE == retNode.getNodeType())
    {
      NodeList nodeList = retNode.getChildNodes();                    
      for(int i = 0; i < nodeList.getLength(); i++)
      {
        traverseChildren(listVector, nodeList.item(i), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
      }
    }
    else if(DTM.DOCUMENT_NODE == retNode.getNodeType())
    {
      traverseChildren(listVector, dtm.getNode(node), namespaceURI, localName, isNamespaceURIWildCard, isLocalNameWildCard);
    }
  }
  int size = listVector.size();
  NodeSet nodeSet = new NodeSet(size);
  for (int i = 0; i < size; i++)
  {
    nodeSet.addNode((Node)listVector.elementAt(i));
  }
  return (NodeList) nodeSet;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:38,代码来源:DTMNodeProxy.java

示例7: execute

/**
 * 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
{

  int context = getArg0AsNode(xctxt);
  
  String s;
  if(context != DTM.NULL)
  {
    DTM dtm = xctxt.getDTM(context);
    int t = dtm.getNodeType(context);
    if(t == DTM.ELEMENT_NODE)
    {
      s = dtm.getNamespaceURI(context);
    }
    else if(t == DTM.ATTRIBUTE_NODE)
    {

      // This function always returns an empty string for namespace nodes.
      // We check for those here.  Fix inspired by Davanum Srinivas.

      s = dtm.getNodeName(context);
      if(s.startsWith("xmlns:") || s.equals("xmlns"))
        return XString.EMPTYSTRING;

      s = dtm.getNamespaceURI(context);
    }
    else
      return XString.EMPTYSTRING;
  }
  else 
    return XString.EMPTYSTRING;
  
  return ((null == s) ? XString.EMPTYSTRING : new XString(s));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:42,代码来源:FuncNamespace.java

示例8: execute

/**
 * 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 lang = m_arg0.execute(xctxt).str();
  int parent = xctxt.getCurrentNode();
  boolean isLang = false;
  DTM dtm = xctxt.getDTM(parent);

  while (DTM.NULL != parent)
  {
    if (DTM.ELEMENT_NODE == dtm.getNodeType(parent))
    {
      int langAttr = dtm.getAttributeNode(parent, "http://www.w3.org/XML/1998/namespace", "lang");

      if (DTM.NULL != langAttr)
      {
        String langVal = dtm.getNodeValue(langAttr);
        // %OPT%
        if (langVal.toLowerCase().startsWith(lang.toLowerCase()))
        {
          int valLen = lang.length();

          if ((langVal.length() == valLen)
                  || (langVal.charAt(valLen) == '-'))
          {
            isLang = true;
          }
        }

        break;
      }
    }

    parent = dtm.getParent(parent);
  }

  return isLang ? XBoolean.S_TRUE : XBoolean.S_FALSE;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:46,代码来源:FuncLang.java

示例9: postInitialization

/**
 * After constructing the translet object, this method must be called to
 * perform any version-specific post-initialization that's required.
 */
public final void postInitialization() {
    // If the version of the translet had just one namesArray, split
    // it into multiple fields.
    if (transletVersion < VER_SPLIT_NAMES_ARRAY) {
        int arraySize = namesArray.length;
        String[] newURIsArray = new String[arraySize];
        String[] newNamesArray = new String[arraySize];
        int[] newTypesArray = new int[arraySize];

        for (int i = 0; i < arraySize; i++) {
            String name = namesArray[i];
            int colonIndex = name.lastIndexOf(':');
            int lNameStartIdx = colonIndex+1;

            if (colonIndex > -1) {
                newURIsArray[i] = name.substring(0, colonIndex);
            }

           // Distinguish attribute and element names.  Attribute has
           // @ before local part of name.
           if (name.charAt(lNameStartIdx) == '@') {
               lNameStartIdx++;
               newTypesArray[i] = DTM.ATTRIBUTE_NODE;
           } else if (name.charAt(lNameStartIdx) == '?') {
               lNameStartIdx++;
               newTypesArray[i] = DTM.NAMESPACE_NODE;
           } else {
               newTypesArray[i] = DTM.ELEMENT_NODE;
           }
           newNamesArray[i] =
                      (lNameStartIdx == 0) ? name
                                           : name.substring(lNameStartIdx);
        }

        namesArray = newNamesArray;
        urisArray  = newURIsArray;
        typesArray = newTypesArray;
    }

    // Was translet compiled using a more recent version of the XSLTC
    // compiler than is known by the AbstractTranslet class?  If, so
    // and we've made it this far (which is doubtful), we should give up.
    if (transletVersion > CURRENT_TRANSLET_VERSION) {
        BasisLibrary.runTimeError(BasisLibrary.UNKNOWN_TRANSLET_VERSION_ERR,
                                  this.getClass().getName());
    }
}
 
开发者ID:apache,项目名称:servicemix-bundles,代码行数:51,代码来源:AbstractTranslet.java

示例10: getHead

/**
 * Get the head of the most likely list of associations to check, based on 
 * the name and type of the targetNode argument.
 *
 * @param xctxt The XPath runtime context.
 * @param targetNode The target node that will be checked for a match.
 * @param dtm The dtm owner for the target node.
 *
 * @return The head of a linked list that contains all possible match pattern to 
 * template associations.
 */
public TemplateSubPatternAssociation getHead(XPathContext xctxt, 
                                             int targetNode, DTM dtm)
{
  short targetNodeType = dtm.getNodeType(targetNode);
  TemplateSubPatternAssociation head;

  switch (targetNodeType)
  {
  case DTM.ELEMENT_NODE :
  case DTM.ATTRIBUTE_NODE :
    head = (TemplateSubPatternAssociation) m_patternTable.get(
      dtm.getLocalName(targetNode));
    break;
  case DTM.TEXT_NODE :
  case DTM.CDATA_SECTION_NODE :
    head = m_textPatterns;
    break;
  case DTM.ENTITY_REFERENCE_NODE :
  case DTM.ENTITY_NODE :
    head = (TemplateSubPatternAssociation) m_patternTable.get(
      dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
    break;
  case DTM.PROCESSING_INSTRUCTION_NODE :
    head = (TemplateSubPatternAssociation) m_patternTable.get(
      dtm.getLocalName(targetNode));
    break;
  case DTM.COMMENT_NODE :
    head = m_commentPatterns;
    break;
  case DTM.DOCUMENT_NODE :
  case DTM.DOCUMENT_FRAGMENT_NODE :
    head = m_docPatterns;
    break;
  case DTM.NOTATION_NODE :
  default :
    head = (TemplateSubPatternAssociation) m_patternTable.get(
      dtm.getNodeName(targetNode)); // %REVIEW% I think this is right
  }

  return (null == head) ? m_wildCardPatterns : head;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:52,代码来源:TemplateList.java

示例11: execute

/**
 * The xsl:copy element provides an easy way of copying the current node.
 * Executing this function creates a copy of the current node into the
 * result tree.
 * <p>The namespace nodes of the current node are automatically
 * copied as well, but the attributes and children of the node are not
 * automatically copied. The content of the xsl:copy element is a
 * template for the attributes and children of the created node;
 * the content is instantiated only for nodes of types that can have
 * attributes or children (i.e. root nodes and element nodes).</p>
 * <p>The root node is treated specially because the root node of the
 * result tree is created implicitly. When the current node is the
 * root node, xsl:copy will not create a root node, but will just use
 * the content template.</p>
 *
 * @param transformer non-null reference to the the current transform-time state.
 *
 * @throws TransformerException
 */
public void execute(
        TransformerImpl transformer)
          throws TransformerException
{
              XPathContext xctxt = transformer.getXPathContext();
    
  try
  {
    int sourceNode = xctxt.getCurrentNode();
    xctxt.pushCurrentNode(sourceNode);
    DTM dtm = xctxt.getDTM(sourceNode);
    short nodeType = dtm.getNodeType(sourceNode);

    if ((DTM.DOCUMENT_NODE != nodeType) && (DTM.DOCUMENT_FRAGMENT_NODE != nodeType))
    {
      SerializationHandler rthandler = transformer.getSerializationHandler();

      // TODO: Process the use-attribute-sets stuff
      ClonerToResultTree.cloneToResultTree(sourceNode, nodeType, dtm, 
                                           rthandler, false);

      if (DTM.ELEMENT_NODE == nodeType)
      {
        super.execute(transformer);
        SerializerUtils.processNSDecls(rthandler, sourceNode, nodeType, dtm);
        transformer.executeChildTemplates(this, true);
        
        String ns = dtm.getNamespaceURI(sourceNode);
        String localName = dtm.getLocalName(sourceNode);
        transformer.getResultTreeHandler().endElement(ns, localName,
                                                      dtm.getNodeName(sourceNode));
      }
    }
    else
    {
      super.execute(transformer);
      transformer.executeChildTemplates(this, true);
    }
  }
  catch(org.xml.sax.SAXException se)
  {
    throw new TransformerException(se);
  }
  finally
  {
    xctxt.popCurrentNode();
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:67,代码来源:ElemCopy.java

示例12: startNode

/**
 * Start traversal of the tree at the given node
 *
 *
 * @param node Starting node for traversal
 *
 * @throws TransformerException
 */
protected void startNode(int node) throws org.xml.sax.SAXException
{

  XPathContext xcntxt = m_transformer.getXPathContext();
  try
  {
    
    if (DTM.ELEMENT_NODE == m_dtm.getNodeType(node))
    {
      xcntxt.pushCurrentNode(node);                   
                                      
      if(m_startNode != node)
      {
        super.startNode(node);
      }
      else
      {
        String elemName = m_dtm.getNodeName(node);
        String localName = m_dtm.getLocalName(node);
        String namespace = m_dtm.getNamespaceURI(node);
                                      
        //xcntxt.pushCurrentNode(node);       
        // SAX-like call to allow adding attributes afterwards
        m_handler.startElement(namespace, localName, elemName);
        boolean hasNSDecls = false;
        DTM dtm = m_dtm;
        for (int ns = dtm.getFirstNamespaceNode(node, true); 
             DTM.NULL != ns; ns = dtm.getNextNamespaceNode(node, ns, true))
        {
          SerializerUtils.ensureNamespaceDeclDeclared(m_handler,dtm, ns);
        }
                                              
                                              
        for (int attr = dtm.getFirstAttribute(node); 
             DTM.NULL != attr; attr = dtm.getNextAttribute(attr))
        {
          SerializerUtils.addAttribute(m_handler, attr);
        }
      }
                              
    }
    else
    {
      xcntxt.pushCurrentNode(node);
      super.startNode(node);
      xcntxt.popCurrentNode();
    }
  }
  catch(javax.xml.transform.TransformerException te)
  {
    throw new org.xml.sax.SAXException(te);
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:61,代码来源:TreeWalker2Result.java

示例13: endNode

/**
 * End processing of given node 
 *
 *
 * @param node Node we just finished processing
 *
 * @throws org.xml.sax.SAXException
 */
protected void endNode(int node) throws org.xml.sax.SAXException
{

  switch (m_dtm.getNodeType(node))
  {
  case DTM.DOCUMENT_NODE :
    this.m_contentHandler.endDocument();
    break;
  case DTM.ELEMENT_NODE :
    String ns = m_dtm.getNamespaceURI(node);
    if(null == ns)
      ns = "";
    this.m_contentHandler.endElement(ns,
                                       m_dtm.getLocalName(node),
                                       m_dtm.getNodeName(node));

    for (int nsn = m_dtm.getFirstNamespaceNode(node, true); DTM.NULL != nsn;
         nsn = m_dtm.getNextNamespaceNode(node, nsn, true))
    {
      // String prefix = m_dtm.getPrefix(nsn);
      String prefix = m_dtm.getNodeNameX(nsn);

      this.m_contentHandler.endPrefixMapping(prefix);
    }
    break;
  case DTM.CDATA_SECTION_NODE :
    break;
  case DTM.ENTITY_REFERENCE_NODE :
  {
    if (m_contentHandler instanceof LexicalHandler)
    {
      LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);

      lh.endEntity(m_dtm.getNodeName(node));
    }
  }
  break;
  default :
  }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:48,代码来源:DTMTreeWalker.java

示例14: getAttributeNode

/**
 * Retrieves an attribute node by by qualified name and namespace URI.
 *
 * @param nodeHandle int Handle of the node upon which to look up this attribute..
 * @param namespaceURI The namespace URI of the attribute to
 *   retrieve, or null.
 * @param name The local name of the attribute to
 *   retrieve.
 * @return The attribute node handle with the specified name (
 *   <code>nodeName</code>) or <code>DTM.NULL</code> if there is no such
 *   attribute.
 */
public int getAttributeNode(int nodeHandle, String namespaceURI,
                            String name)
{

  // %OPT% This is probably slower than it needs to be.
  if (null == namespaceURI)
    namespaceURI = "";

  int type = getNodeType(nodeHandle);

  if (DTM.ELEMENT_NODE == type)
  {

    // Assume that attributes immediately follow the element.
    int identity = makeNodeIdentity(nodeHandle);

    while (DTM.NULL != (identity = getNextNodeIdentity(identity)))
    {
      // Assume this can not be null.
      type = _type(identity);

		// %REVIEW%
		// Should namespace nodes be retrievable DOM-style as attrs?
		// If not we need a separate function... which may be desirable
		// architecturally, but which is ugly from a code point of view.
		// (If we REALLY insist on it, this code should become a subroutine
		// of both -- retrieve the node, then test if the type matches
		// what you're looking for.)
      if (type == DTM.ATTRIBUTE_NODE || type==DTM.NAMESPACE_NODE)
      {
        Node node = lookupNode(identity);
        String nodeuri = node.getNamespaceURI();

        if (null == nodeuri)
          nodeuri = "";

        String nodelocalname = node.getLocalName();

        if (nodeuri.equals(namespaceURI) && name.equals(nodelocalname))
          return makeNodeHandle(identity);
      }
		
      else // if (DTM.NAMESPACE_NODE != type)
      {
        break;
      }
    }
  }

  return DTM.NULL;
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:63,代码来源:DOM2DTM.java

示例15: getNodeTypeTest

/**
 * Tell what node type to test, if not DTMFilter.SHOW_ALL.
 *
 * @param whatToShow Bit set defined mainly by 
 *        {@link org.apache.xml.dtm.DTMFilter}.
 * @return the node type for the whatToShow.  Since whatToShow can specify 
 *         multiple types, it will return the first bit tested that is on, 
 *         so the caller of this function should take care that this is 
 *         the function they really want to call.  If none of the known bits
 *         are set, this function will return zero.
 */
public static int getNodeTypeTest(int whatToShow)
{
  // %REVIEW% Is there a better way?
  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    return DTM.ELEMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    return DTM.ATTRIBUTE_NODE;
    
  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    return DTM.TEXT_NODE;
    
  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    return DTM.DOCUMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    return DTM.DOCUMENT_FRAGMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    return DTM.NAMESPACE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    return DTM.COMMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    return DTM.PROCESSING_INSTRUCTION_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    return DTM.DOCUMENT_TYPE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    return DTM.ENTITY_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    return DTM.ENTITY_REFERENCE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    return DTM.NOTATION_NODE;
    
  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    return DTM.CDATA_SECTION_NODE;


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


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