Author: jukka Date: Tue Mar 18 15:18:07 2008 New Revision: 638609 URL: http://svn.apache.org/viewvc?rev=638609&view=rev Log: TIKA-129: node() support for the streaming XPath utility
Added: incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/NodeMatcher.java Modified: incubator/tika/trunk/CHANGES.txt incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/XPathParser.java Modified: incubator/tika/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/tika/trunk/CHANGES.txt?rev=638609&r1=638608&r2=638609&view=diff ============================================================================== --- incubator/tika/trunk/CHANGES.txt (original) +++ incubator/tika/trunk/CHANGES.txt Tue Mar 18 15:18:07 2008 @@ -24,6 +24,8 @@ 10. TIKA-127 - Add support for Visio files (Jukka Zitting) +11. TIKA-129 - node() support for the streaming XPath utility (Jukka Zitting) + Release 0.1-incubating - 12/27/2007 Added: incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/NodeMatcher.java URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/NodeMatcher.java?rev=638609&view=auto ============================================================================== --- incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/NodeMatcher.java (added) +++ incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/NodeMatcher.java Tue Mar 18 15:18:07 2008 @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tika.sax.xpath; + +/** + * Final evaluation state of a <code>.../node()</code> XPath expression. + * Matches all elements, attributes, and text. + */ +public class NodeMatcher extends Matcher { + + public static final Matcher INSTANCE = new NodeMatcher(); + + @Override + public boolean matchesElement() { + return true; + } + + @Override + public boolean matchesAttribute(String namespace, String name) { + return true; + } + + @Override + public boolean matchesText() { + return true; + } + +} Modified: incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/XPathParser.java URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/XPathParser.java?rev=638609&r1=638608&r2=638609&view=diff ============================================================================== --- incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/XPathParser.java (original) +++ incubator/tika/trunk/src/main/java/org/apache/tika/sax/xpath/XPathParser.java Tue Mar 18 15:18:07 2008 @@ -58,6 +58,8 @@ public Matcher parse(String xpath) { if (xpath.equals("/text()")) { return TextMatcher.INSTANCE; + } else if (xpath.equals("/node()")) { + return NodeMatcher.INSTANCE; } else if (xpath.equals("/@*")) { return AttributeMatcher.INSTANCE; } else if (xpath.length() == 0) {