Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTMFilter#SHOW_DOCUMENT_FRAGMENT

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMFilter#SHOW_DOCUMENT_FRAGMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StepPattern.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example 2
Source File: StepPattern.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example 3
Source File: StepPattern.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example 4
Source File: NodeTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Do a diagnostics dump of a whatToShow bit set.
 *
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 */
public static void debugWhatToShow(int whatToShow)
{

  java.util.Vector v = new java.util.Vector();

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    v.addElement("SHOW_ATTRIBUTE");

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    v.addElement("SHOW_NAMESPACE");

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    v.addElement("SHOW_CDATA_SECTION");

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    v.addElement("SHOW_COMMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    v.addElement("SHOW_DOCUMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    v.addElement("SHOW_DOCUMENT_FRAGMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    v.addElement("SHOW_DOCUMENT_TYPE");

  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    v.addElement("SHOW_ELEMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    v.addElement("SHOW_ENTITY");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    v.addElement("SHOW_ENTITY_REFERENCE");

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    v.addElement("SHOW_NOTATION");

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    v.addElement("SHOW_PROCESSING_INSTRUCTION");

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    v.addElement("SHOW_TEXT");

  int n = v.size();

  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      System.out.print(" | ");

    System.out.print(v.elementAt(i));
  }

  if (0 == n)
    System.out.print("empty whatToShow: " + whatToShow);

  System.out.println();
}
 
Example 5
Source File: NodeTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTM dtm = xctxt.getDTM(context);
  short nodeType = dtm.getNodeType(context);

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 6
Source File: NodeTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context,
                       DTM dtm, int expType)
        throws javax.xml.transform.TransformerException
{

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001
                 << ((dtm.getNodeType(context)) - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 7
Source File: NodeTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context,
                       DTM dtm, int expType)
        throws javax.xml.transform.TransformerException
{

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001
                 << ((dtm.getNodeType(context)) - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 8
Source File: NodeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTM dtm = xctxt.getDTM(context);
  short nodeType = dtm.getNodeType(context);

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 9
Source File: StepPattern.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the string represenentation of this step for diagnostic purposes.
 *
 *
 * @return A string representation of this step, built by reverse-engineering
 * the contained info.
 */
public String toString()
{

  StringBuffer buf = new StringBuffer();

  for (StepPattern pat = this; pat != null; pat = pat.m_relativePathPattern)
  {
    if (pat != this)
      buf.append("/");

    buf.append(Axis.getNames(pat.m_axis));
    buf.append("::");

    if (0x000005000 == pat.m_whatToShow)
    {
      buf.append("doc()");
    }
    else if (DTMFilter.SHOW_BYFUNCTION == pat.m_whatToShow)
    {
      buf.append("function()");
    }
    else if (DTMFilter.SHOW_ALL == pat.m_whatToShow)
    {
      buf.append("node()");
    }
    else if (DTMFilter.SHOW_TEXT == pat.m_whatToShow)
    {
      buf.append("text()");
    }
    else if (DTMFilter.SHOW_PROCESSING_INSTRUCTION == pat.m_whatToShow)
    {
      buf.append("processing-instruction(");

      if (null != pat.m_name)
      {
        buf.append(pat.m_name);
      }

      buf.append(")");
    }
    else if (DTMFilter.SHOW_COMMENT == pat.m_whatToShow)
    {
      buf.append("comment()");
    }
    else if (null != pat.m_name)
    {
      if (DTMFilter.SHOW_ATTRIBUTE == pat.m_whatToShow)
      {
        buf.append("@");
      }

      if (null != pat.m_namespace)
      {
        buf.append("{");
        buf.append(pat.m_namespace);
        buf.append("}");
      }

      buf.append(pat.m_name);
    }
    else if (DTMFilter.SHOW_ATTRIBUTE == pat.m_whatToShow)
    {
      buf.append("@");
    }
    else if ((DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT)
             == pat.m_whatToShow)
    {
      buf.append("doc-root()");
    }
    else
    {
      buf.append('?').append(Integer.toHexString(pat.m_whatToShow));
    }

    if (null != pat.m_predicates)
    {
      for (int i = 0; i < pat.m_predicates.length; i++)
      {
        buf.append("[");
        buf.append(pat.m_predicates[i]);
        buf.append("]");
      }
    }
  }

  return buf.toString();
}
 
Example 10
Source File: NodeTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context,
                       DTM dtm, int expType)
        throws javax.xml.transform.TransformerException
{

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001
                 << ((dtm.getNodeType(context)) - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 11
Source File: Compiler.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   * to show for a given node test.
   *
   * @param opPos the op map position for the location step.
   *
   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   *         to show for a given node test.
   */
  public int getWhatToShow(int opPos)
  {

    int axesType = getOp(opPos);
    int testType = getOp(opPos + 3);

    // System.out.println("testType: "+testType);
    switch (testType)
    {
    case OpCodes.NODETYPE_COMMENT :
      return DTMFilter.SHOW_COMMENT;
    case OpCodes.NODETYPE_TEXT :
//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
    case OpCodes.NODETYPE_PI :
      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
    case OpCodes.NODETYPE_NODE :
//      return DTMFilter.SHOW_ALL;
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE:
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;
      case OpCodes.FROM_SELF:
      case OpCodes.FROM_ANCESTORS_OR_SELF:
      case OpCodes.FROM_DESCENDANTS_OR_SELF:
        return DTMFilter.SHOW_ALL;
      default:
        if (getOp(0) == OpCodes.OP_MATCHPATTERN)
          return ~DTMFilter.SHOW_ATTRIBUTE
                  & ~DTMFilter.SHOW_DOCUMENT
                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
        else
          return ~DTMFilter.SHOW_ATTRIBUTE;
      }
    case OpCodes.NODETYPE_ROOT :
      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
    case OpCodes.NODETYPE_FUNCTEST :
      return NodeTest.SHOW_BYFUNCTION;
    case OpCodes.NODENAME :
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE :
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;

      // break;
      case OpCodes.MATCH_ANY_ANCESTOR :
      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
        return DTMFilter.SHOW_ELEMENT;

      // break;
      default :
        return DTMFilter.SHOW_ELEMENT;
      }
    default :
      // System.err.println("We should never reach here.");
      return DTMFilter.SHOW_ALL;
    }
  }
 
Example 12
Source File: NodeTest.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Do a diagnostics dump of a whatToShow bit set.
 *
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 */
public static void debugWhatToShow(int whatToShow)
{

  java.util.Vector v = new java.util.Vector();

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    v.addElement("SHOW_ATTRIBUTE");

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    v.addElement("SHOW_NAMESPACE");

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    v.addElement("SHOW_CDATA_SECTION");

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    v.addElement("SHOW_COMMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    v.addElement("SHOW_DOCUMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    v.addElement("SHOW_DOCUMENT_FRAGMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    v.addElement("SHOW_DOCUMENT_TYPE");

  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    v.addElement("SHOW_ELEMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    v.addElement("SHOW_ENTITY");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    v.addElement("SHOW_ENTITY_REFERENCE");

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    v.addElement("SHOW_NOTATION");

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    v.addElement("SHOW_PROCESSING_INSTRUCTION");

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    v.addElement("SHOW_TEXT");

  int n = v.size();

  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      System.out.print(" | ");

    System.out.print(v.elementAt(i));
  }

  if (0 == n)
    System.out.print("empty whatToShow: " + whatToShow);

  System.out.println();
}
 
Example 13
Source File: Compiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   * to show for a given node test.
   *
   * @param opPos the op map position for the location step.
   *
   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   *         to show for a given node test.
   */
  public int getWhatToShow(int opPos)
  {

    int axesType = getOp(opPos);
    int testType = getOp(opPos + 3);

    // System.out.println("testType: "+testType);
    switch (testType)
    {
    case OpCodes.NODETYPE_COMMENT :
      return DTMFilter.SHOW_COMMENT;
    case OpCodes.NODETYPE_TEXT :
//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
    case OpCodes.NODETYPE_PI :
      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
    case OpCodes.NODETYPE_NODE :
//      return DTMFilter.SHOW_ALL;
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE:
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;
      case OpCodes.FROM_SELF:
      case OpCodes.FROM_ANCESTORS_OR_SELF:
      case OpCodes.FROM_DESCENDANTS_OR_SELF:
        return DTMFilter.SHOW_ALL;
      default:
        if (getOp(0) == OpCodes.OP_MATCHPATTERN)
          return ~DTMFilter.SHOW_ATTRIBUTE
                  & ~DTMFilter.SHOW_DOCUMENT
                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
        else
          return ~DTMFilter.SHOW_ATTRIBUTE;
      }
    case OpCodes.NODETYPE_ROOT :
      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
    case OpCodes.NODETYPE_FUNCTEST :
      return NodeTest.SHOW_BYFUNCTION;
    case OpCodes.NODENAME :
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE :
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;

      // break;
      case OpCodes.MATCH_ANY_ANCESTOR :
      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
        return DTMFilter.SHOW_ELEMENT;

      // break;
      default :
        return DTMFilter.SHOW_ELEMENT;
      }
    default :
      // System.err.println("We should never reach here.");
      return DTMFilter.SHOW_ALL;
    }
  }
 
Example 14
Source File: NodeTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTM dtm = xctxt.getDTM(context);
  short nodeType = dtm.getNodeType(context);

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 15
Source File: Compiler.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   * to show for a given node test.
   *
   * @param opPos the op map position for the location step.
   *
   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   *         to show for a given node test.
   */
  public int getWhatToShow(int opPos)
  {

    int axesType = getOp(opPos);
    int testType = getOp(opPos + 3);

    // System.out.println("testType: "+testType);
    switch (testType)
    {
    case OpCodes.NODETYPE_COMMENT :
      return DTMFilter.SHOW_COMMENT;
    case OpCodes.NODETYPE_TEXT :
//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
    case OpCodes.NODETYPE_PI :
      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
    case OpCodes.NODETYPE_NODE :
//      return DTMFilter.SHOW_ALL;
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE:
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;
      case OpCodes.FROM_SELF:
      case OpCodes.FROM_ANCESTORS_OR_SELF:
      case OpCodes.FROM_DESCENDANTS_OR_SELF:
        return DTMFilter.SHOW_ALL;
      default:
        if (getOp(0) == OpCodes.OP_MATCHPATTERN)
          return ~DTMFilter.SHOW_ATTRIBUTE
                  & ~DTMFilter.SHOW_DOCUMENT
                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
        else
          return ~DTMFilter.SHOW_ATTRIBUTE;
      }
    case OpCodes.NODETYPE_ROOT :
      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
    case OpCodes.NODETYPE_FUNCTEST :
      return NodeTest.SHOW_BYFUNCTION;
    case OpCodes.NODENAME :
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE :
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;

      // break;
      case OpCodes.MATCH_ANY_ANCESTOR :
      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
        return DTMFilter.SHOW_ELEMENT;

      // break;
      default :
        return DTMFilter.SHOW_ELEMENT;
      }
    default :
      // System.err.println("We should never reach here.");
      return DTMFilter.SHOW_ALL;
    }
  }
 
Example 16
Source File: NodeTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTM dtm = xctxt.getDTM(context);
  short nodeType = dtm.getNodeType(context);

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 17
Source File: NodeTest.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Do a diagnostics dump of a whatToShow bit set.
 *
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 */
public static void debugWhatToShow(int whatToShow)
{

  java.util.Vector v = new java.util.Vector();

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    v.addElement("SHOW_ATTRIBUTE");

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    v.addElement("SHOW_NAMESPACE");

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    v.addElement("SHOW_CDATA_SECTION");

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    v.addElement("SHOW_COMMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    v.addElement("SHOW_DOCUMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    v.addElement("SHOW_DOCUMENT_FRAGMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    v.addElement("SHOW_DOCUMENT_TYPE");

  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    v.addElement("SHOW_ELEMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    v.addElement("SHOW_ENTITY");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    v.addElement("SHOW_ENTITY_REFERENCE");

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    v.addElement("SHOW_NOTATION");

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    v.addElement("SHOW_PROCESSING_INSTRUCTION");

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    v.addElement("SHOW_TEXT");

  int n = v.size();

  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      System.out.print(" | ");

    System.out.print(v.elementAt(i));
  }

  if (0 == n)
    System.out.print("empty whatToShow: " + whatToShow);

  System.out.println();
}
 
Example 18
Source File: NodeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Do a diagnostics dump of a whatToShow bit set.
 *
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 */
public static void debugWhatToShow(int whatToShow)
{

  java.util.Vector v = new java.util.Vector();

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    v.addElement("SHOW_ATTRIBUTE");

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    v.addElement("SHOW_NAMESPACE");

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    v.addElement("SHOW_CDATA_SECTION");

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    v.addElement("SHOW_COMMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    v.addElement("SHOW_DOCUMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    v.addElement("SHOW_DOCUMENT_FRAGMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    v.addElement("SHOW_DOCUMENT_TYPE");

  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    v.addElement("SHOW_ELEMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    v.addElement("SHOW_ENTITY");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    v.addElement("SHOW_ENTITY_REFERENCE");

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    v.addElement("SHOW_NOTATION");

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    v.addElement("SHOW_PROCESSING_INSTRUCTION");

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    v.addElement("SHOW_TEXT");

  int n = v.size();

  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      System.out.print(" | ");

    System.out.print(v.elementAt(i));
  }

  if (0 == n)
    System.out.print("empty whatToShow: " + whatToShow);

  System.out.println();
}
 
Example 19
Source File: NodeTest.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context)
        throws javax.xml.transform.TransformerException
{

  DTM dtm = xctxt.getDTM(context);
  short nodeType = dtm.getNodeType(context);

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001 << (nodeType - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example 20
Source File: NodeTest.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Do a diagnostics dump of a whatToShow bit set.
 *
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 */
public static void debugWhatToShow(int whatToShow)
{

  java.util.Vector v = new java.util.Vector();

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    v.addElement("SHOW_ATTRIBUTE");

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    v.addElement("SHOW_NAMESPACE");

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    v.addElement("SHOW_CDATA_SECTION");

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    v.addElement("SHOW_COMMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    v.addElement("SHOW_DOCUMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    v.addElement("SHOW_DOCUMENT_FRAGMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    v.addElement("SHOW_DOCUMENT_TYPE");

  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    v.addElement("SHOW_ELEMENT");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    v.addElement("SHOW_ENTITY");

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    v.addElement("SHOW_ENTITY_REFERENCE");

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    v.addElement("SHOW_NOTATION");

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    v.addElement("SHOW_PROCESSING_INSTRUCTION");

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    v.addElement("SHOW_TEXT");

  int n = v.size();

  for (int i = 0; i < n; i++)
  {
    if (i > 0)
      System.out.print(" | ");

    System.out.print(v.elementAt(i));
  }

  if (0 == n)
    System.out.print("empty whatToShow: " + whatToShow);

  System.out.println();
}