Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTMFilter#SHOW_ATTRIBUTE
The following examples show how to use
com.sun.org.apache.xml.internal.dtm.DTMFilter#SHOW_ATTRIBUTE .
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: BasicTestIterator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Create a LocPathIterator object, including creation * of step walkers from the opcode list, and call back * into the Compiler to create predicate expressions. * * @param compiler The Compiler which is creating * this expression. * @param opPos The position of this iterator in the * opcode list from the compiler. * * @throws javax.xml.transform.TransformerException */ protected BasicTestIterator(Compiler compiler, int opPos, int analysis) throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis, false); int firstStepPos = OpMap.getFirstChildPos(opPos); int whatToShow = compiler.getWhatToShow(firstStepPos); if ((0 == (whatToShow & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE | DTMFilter.SHOW_ELEMENT | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == DTMFilter.SHOW_ALL)) initNodeTest(whatToShow); else { initNodeTest(whatToShow, compiler.getStepNS(firstStepPos), compiler.getStepLocalName(firstStepPos)); } initPredicateInfo(compiler, firstStepPos); }
Example 2
Source File: BasicTestIterator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Create a LocPathIterator object, including creation * of step walkers from the opcode list, and call back * into the Compiler to create predicate expressions. * * @param compiler The Compiler which is creating * this expression. * @param opPos The position of this iterator in the * opcode list from the compiler. * * @throws javax.xml.transform.TransformerException */ protected BasicTestIterator(Compiler compiler, int opPos, int analysis) throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis, false); int firstStepPos = OpMap.getFirstChildPos(opPos); int whatToShow = compiler.getWhatToShow(firstStepPos); if ((0 == (whatToShow & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE | DTMFilter.SHOW_ELEMENT | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == DTMFilter.SHOW_ALL)) initNodeTest(whatToShow); else { initNodeTest(whatToShow, compiler.getStepNS(firstStepPos), compiler.getStepLocalName(firstStepPos)); } initPredicateInfo(compiler, firstStepPos); }
Example 3
Source File: BasicTestIterator.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Create a LocPathIterator object, including creation * of step walkers from the opcode list, and call back * into the Compiler to create predicate expressions. * * @param compiler The Compiler which is creating * this expression. * @param opPos The position of this iterator in the * opcode list from the compiler. * * @throws javax.xml.transform.TransformerException */ protected BasicTestIterator(Compiler compiler, int opPos, int analysis) throws javax.xml.transform.TransformerException { super(compiler, opPos, analysis, false); int firstStepPos = OpMap.getFirstChildPos(opPos); int whatToShow = compiler.getWhatToShow(firstStepPos); if ((0 == (whatToShow & (DTMFilter.SHOW_ATTRIBUTE | DTMFilter.SHOW_NAMESPACE | DTMFilter.SHOW_ELEMENT | DTMFilter.SHOW_PROCESSING_INSTRUCTION))) || (whatToShow == DTMFilter.SHOW_ALL)) initNodeTest(whatToShow); else { initNodeTest(whatToShow, compiler.getStepNS(firstStepPos), compiler.getStepLocalName(firstStepPos)); } initPredicateInfo(compiler, firstStepPos); }
Example 4
Source File: NodeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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 5
Source File: NodeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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 6
Source File: StepPattern.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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 7
Source File: NodeTest.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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 jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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: NodeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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 10
Source File: Compiler.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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 11
Source File: NodeTest.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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; }
Example 12
Source File: StepPattern.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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 13
Source File: NodeTest.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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 14
Source File: NodeTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example 15
Source File: NodeTest.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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 16
Source File: NodeTest.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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; }
Example 17
Source File: NodeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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 18
Source File: NodeTest.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * 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 19
Source File: NodeTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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; }
Example 20
Source File: NodeTest.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * 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(); }