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


Java DTM.ATTRIBUTE_NODE属性代码示例

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


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

示例1: setParser

public void setParser(Parser parser) {
    super.setParser(parser);
    // find all expressions in this Union
    final Vector components = new Vector();
    flatten(components);
    final int size = components.size();
    _components = (Expression[])components.toArray(new Expression[size]);
    for (int i = 0; i < size; i++) {
        _components[i].setParser(parser);
        _components[i].setParent(this);
        if (_components[i] instanceof Step) {
            final Step step = (Step)_components[i];
            final int axis = step.getAxis();
            final int type = step.getNodeType();
            // Put attribute iterators first
            if ((axis == Axis.ATTRIBUTE) || (type == DTM.ATTRIBUTE_NODE)) {
                _components[i] = _components[0];
                _components[0] = step;
            }
            // Check if the union contains a reverse iterator
    if (Axis.isReverse(axis)) _reverse = true;
        }
    }
    // No need to reverse anything if another expression lies on top of this
    if (getParent() instanceof Expression) _reverse = false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:UnionPathExpr.java

示例2: getNextAttributeIdentity

/**
 * The optimized version of DTMDefaultBase.getNextAttributeIdentity(int).
 * <p>
 * Given a node identity for an attribute, advance to the next attribute.
 *
 * @param identity int identity of the attribute node.  This
 * <strong>must</strong> be an attribute node.
 *
 * @return int DTM node-identity of the resolved attr,
 * or DTM.NULL to indicate none exists.
 *
 */
protected int getNextAttributeIdentity(int identity) {
  // Assume that attributes and namespace nodes immediately follow the element
  while (true) {
    identity++;
    int type = _type2(identity);

    if (type == DTM.ATTRIBUTE_NODE) {
      return identity;
    } else if (type != DTM.NAMESPACE_NODE) {
      break;
    }
  }

  return DTM.NULL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:SAX2DTM2.java

示例3: getGeneralizedType

/**
 * Returns the internal type associated with an expanded QName
 */
public int getGeneralizedType(final String name, boolean searchOnly) {
    String lName, ns = null;
    int index = -1;
    int code;

    // Is there a prefix?
    if ((index = name.lastIndexOf(":"))> -1) {
        ns = name.substring(0, index);
    }

    // Local part of name is after colon.  lastIndexOf returns -1 if
    // there is no colon, so lNameStartIdx will be zero in that case.
    int lNameStartIdx = index+1;

    // Distinguish attribute and element names.  Attribute has @ before
    // local part of name.
    if (name.charAt(lNameStartIdx) == '@') {
        code = DTM.ATTRIBUTE_NODE;
        lNameStartIdx++;
    }
    else {
        code = DTM.ELEMENT_NODE;
    }

    // Extract local name
    lName = (lNameStartIdx == 0) ? name : name.substring(lNameStartIdx);

    return m_expandedNameTable.getExpandedTypeID(ns, lName, code, searchOnly);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:32,代码来源:SAXImpl.java

示例4: isAttributeSpecified

/**
 *     5. [specified] A flag indicating whether this attribute was actually
 *        specified in the start-tag of its element, or was defaulted from the
 *        DTD.
 *
 * @param attributeHandle the attribute handle
 * @return <code>true</code> if the attribute was specified;
 *         <code>false</code> if it was defaulted.
 */
public boolean isAttributeSpecified(int attributeHandle)
{
  int type = getNodeType(attributeHandle);

  if (DTM.ATTRIBUTE_NODE == type)
  {
    Attr attr = (Attr)getNode(attributeHandle);
    return attr.getSpecified();
  }
  return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DOM2DTM.java

示例5: 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:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:FuncNamespace.java

示例6: getNextNamespaceNode2

/**
 * Return the next namespace node following the given base node.
 *
 * @baseID The node identity of the base node, which can be an
 * element, attribute or namespace node.
 * @return The namespace node immediately following the base node.
 */
protected final int getNextNamespaceNode2(int baseID) {
    int type;
    while ((type = _type2(++baseID)) == DTM.ATTRIBUTE_NODE);

    if (type == DTM.NAMESPACE_NODE)
        return baseID;
    else
        return NULL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:SAX2DTM2.java

示例7: getFirstAttribute

/**
 * The optimized version of DTMDefaultBase.getFirstAttribute().
 * <p>
 * Given a node handle, get the index of the node's first attribute.
 *
 * @param nodeHandle int Handle of the node.
 * @return Handle of first attribute, or DTM.NULL to indicate none exists.
 */
public final int getFirstAttribute(int nodeHandle)
{
  int nodeID = makeNodeIdentity(nodeHandle);

  if (nodeID == DTM.NULL)
    return DTM.NULL;

  int type = _type2(nodeID);

  if (DTM.ELEMENT_NODE == type)
  {
    // Assume that attributes and namespaces immediately follow the element.
    while (true)
    {
      nodeID++;
      // Assume this can not be null.
      type = _type2(nodeID);

      if (type == DTM.ATTRIBUTE_NODE)
      {
        return makeNodeHandle(nodeID);
      }
      else if (DTM.NAMESPACE_NODE != type)
      {
        break;
      }
    }
  }

  return DTM.NULL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:SAX2DTM2.java

示例8: getFirstAttributeIdentity

/**
 * The optimized version of DTMDefaultBase.getFirstAttributeIdentity(int).
 * <p>
 * Given a node identity, get the index of the node's first attribute.
 *
 * @param identity int identity of the node.
 * @return Identity of first attribute, or DTM.NULL to indicate none exists.
 */
protected int getFirstAttributeIdentity(int identity) {
  if (identity == NULL) {
      return NULL;
  }
  int type = _type2(identity);

  if (DTM.ELEMENT_NODE == type)
  {
    // Assume that attributes and namespaces immediately follow the element.
    while (true)
    {
      identity++;

      // Assume this can not be null.
      type = _type2(identity);

      if (type == DTM.ATTRIBUTE_NODE)
      {
        return identity;
      }
      else if (DTM.NAMESPACE_NODE != type)
      {
        break;
      }
    }
  }

  return DTM.NULL;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:SAX2DTM2.java

示例9: isAttribute

/**
 * Returns 'true' if a specific node is an attribute (of any type)
 */
public boolean isAttribute(final int node) {
    return getNodeType(node) == DTM.ATTRIBUTE_NODE;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:SAXImpl.java

示例10: copy

private final void copy(final int node, SerializationHandler handler, boolean isChild)
    throws TransletException
{
 int nodeID = makeNodeIdentity(node);
    int eType = _exptype2(nodeID);
    int type = _exptype2Type(eType);

    try {
        switch(type)
        {
            case DTM.ROOT_NODE:
            case DTM.DOCUMENT_NODE:
                for(int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) {
                    copy(makeNodeHandle(c), handler, true);
                }
                break;
            case DTM.PROCESSING_INSTRUCTION_NODE:
                copyPI(node, handler);
                break;
            case DTM.COMMENT_NODE:
                handler.comment(getStringValueX(node));
                break;
            case DTM.TEXT_NODE:
                boolean oldEscapeSetting = false;
                boolean escapeBit = false;

                if (_dontEscape != null) {
                    escapeBit = _dontEscape.getBit(getNodeIdent(node));
                    if (escapeBit) {
                        oldEscapeSetting = handler.setEscaping(false);
                    }
                }

                copyTextNode(nodeID, handler);

                if (escapeBit) {
                    handler.setEscaping(oldEscapeSetting);
                }
                break;
            case DTM.ATTRIBUTE_NODE:
                copyAttribute(nodeID, eType, handler);
                break;
            case DTM.NAMESPACE_NODE:
                handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node));
                break;
            default:
                if (type == DTM.ELEMENT_NODE)
                {
                    // Start element definition
                    final String name = copyElement(nodeID, eType, handler);
                    //if(isChild) => not to copy any namespaces  from parents
                    // else copy all namespaces in scope
                    copyNS(nodeID, handler,!isChild);
                    copyAttributes(nodeID, handler);
                    // Copy element children
                    for (int c = _firstch2(nodeID); c != DTM.NULL; c = _nextsib2(c)) {
                        copy(makeNodeHandle(c), handler, true);
                    }

                    // Close element definition
                    handler.endElement(name);
                }
                // Shallow copy of attribute to output handler
                else {
                    final String uri = getNamespaceName(node);
                    if (uri.length() != 0) {
                        final String prefix = getPrefix(node);
                        handler.namespaceAfterStartElement(prefix, uri);
                    }
                    handler.addAttribute(getNodeName(node), getNodeValue(node));
                }
                break;
        }
    }
    catch (Exception e) {
        throw new TransletException(e);
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:79,代码来源:SAXImpl.java

示例11: shallowCopy

/**
 * Performs a shallow copy (ref. XSLs copy())
 */
public String shallowCopy(final int node, SerializationHandler handler)
    throws TransletException
{
    int nodeID = makeNodeIdentity(node);
    int exptype = _exptype2(nodeID);
    int type = _exptype2Type(exptype);

    try {
        switch(type)
        {
            case DTM.ELEMENT_NODE:
                final String name = copyElement(nodeID, exptype, handler);
                copyNS(nodeID, handler, true);
                return name;
            case DTM.ROOT_NODE:
            case DTM.DOCUMENT_NODE:
                return EMPTYSTRING;
            case DTM.TEXT_NODE:
                copyTextNode(nodeID, handler);
                return null;
            case DTM.PROCESSING_INSTRUCTION_NODE:
                copyPI(node, handler);
                return null;
            case DTM.COMMENT_NODE:
                handler.comment(getStringValueX(node));
                return null;
            case DTM.NAMESPACE_NODE:
                handler.namespaceAfterStartElement(getNodeNameX(node), getNodeValue(node));
                return null;
            case DTM.ATTRIBUTE_NODE:
                copyAttribute(nodeID, exptype, handler);
                return null;
            default:
                final String uri1 = getNamespaceName(node);
                if (uri1.length() != 0) {
                    final String prefix = getPrefix(node);
                    handler.namespaceAfterStartElement(prefix, uri1);
                }
                handler.addAttribute(getNodeName(node), getNodeValue(node));
                return null;
        }
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:48,代码来源:SAXImpl.java

示例12: setStartNode

/**
     * Set start to END should 'close' the iterator,
     * i.e. subsequent call to next() should return END.
     *
     * @param node Sets the root of the iteration.
     *
     * @return A DTMAxisIterator set to the start of the iteration.
     */
    public DTMAxisIterator setStartNode(int node)
    {
//%HZ%: Added reference to DTMDefaultBase.ROOTNODE back in, temporarily
      if (node == DTMDefaultBase.ROOTNODE)
        node = getDocument();
      if (_isRestartable)
      {
        _startNode = node;

        //_currentNode = m_traverser.first(node);

        node = makeNodeIdentity(node);

        int first;
        int type = _type2(node);

        if ((DTM.ATTRIBUTE_NODE == type) || (DTM.NAMESPACE_NODE == type))
        {
          node = _parent2(node);
          first = _firstch2(node);

          if (NULL != first) {
            _currentNode = makeNodeHandle(first);
            return resetPosition();
          }
        }

        do
        {
          first = _nextsib2(node);

          if (NULL == first)
            node = _parent2(node);
        }
        while (NULL == first && NULL != node);

        _currentNode = makeNodeHandle(first);

        // _currentNode precedes possible following(node) nodes
        return resetPosition();
      }

      return this;
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:52,代码来源:SAX2DTM2.java

示例13: getNodeTypeTest

/**
 * Tell what node type to test, if not DTMFilter.SHOW_ALL.
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:56,代码来源:NodeTest.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:SunburstApps,项目名称:OpenJSharp,代码行数:63,代码来源:DOM2DTM.java

示例15: 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:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:AbstractTranslet.java


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