286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2001, 2002,2004,2005 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * @author Andy Clark, IBM 286N/A /** Compile to true to debug everything. */ 286N/A /** Compile to true to debug method callbacks. */ 286N/A /** Compile to true to debug important method callbacks. */ 286N/A /** Compile to true to debug the <em>really</em> important methods. */ 286N/A /** Compile to true to debug match. */ 286N/A /** Compile to true to debug step index stack. */ 286N/A /** Don't touch this value unless you add more debug constants. */ 286N/A // constants describing whether a match was made, 286N/A // matched on the attribute axis 286N/A // matched on the descendant-or-self axixs 286N/A // matched some previous (ancestor) node on the descendant-or-self-axis, but not this node 286N/A /** XPath location path. */ 286N/A /** True if XPath has been matched. */ 286N/A /** The matching string. */ 286N/A /** Integer stack of step indexes. */ 286N/A * No match depth. The value of this field will be zero while 286N/A * matching is successful for the given xpath expression. 286N/A * Constructs an XPath matcher that implements a document fragment 286N/A * @param xpath The xpath. 286N/A * Returns value of first member of fMatched that 286N/A // xpath has been matched if any one of the members of the union have matched. 286N/A // a place-holder method; to be overridden by subclasses 286N/A // that care about matching element content. 286N/A * This method is called when the XPath handler matches the 286N/A * XPath expression. Subclasses can override this method to 286N/A * provide default handling upon a match. 286N/A }
// matched(String content, XSSimpleType val) 286N/A // ~XMLDocumentFragmentHandler methods 286N/A * The start of the document fragment. 286N/A }
// startDocumentFragment() 286N/A * The start of an element. If the document specifies the start element 286N/A * by using an empty tag, then the startElement method will immediately 286N/A * be followed by the endElement method, with no intervening methods. 286N/A * @param element The name of the element. 286N/A * @param attributes The element attributes. 286N/A * @throws SAXException Thrown by handler to signal an error. 286N/A // try next xpath, if not matching 286N/A // consume self::node() steps 286N/A // now if the current step is a descendant step, we let the next 286N/A // step do its thing; if it fails, we reset ourselves 286N/A // to look at this step for next time we're called. 286N/A // so first consume all descendants: 286N/A // match child::... step, if haven't consumed any self::node() 286N/A // match attribute::... step 286N/A // startElement(QName,XMLAttrList,int) 286N/A * content type of this element. IOW, the XML schema type 286N/A * of the <tt>value</tt>. Note that this may not be the type declared 286N/A * in the element declaration, but it is "the actual type". For example, 286N/A * if the XML is <foo xsi:type="xs:string">aaa</foo>, this 286N/A * parameter will be "xs:string". 286N/A * @param nillable - nillable 286N/A * true if the element declaration is nillable. 286N/A * @param value - actual value 286N/A * the typed value of the content of this element. 286N/A // don't do anything, if not matching 286N/A // signal match, if appropriate 286N/A // only certain kinds of matchers actually 286N/A // match element content. This permits 286N/A // them a way to override this to do nothing 286N/A // and hopefully save a few operations. 286N/A /** Returns a string representation of this object. */ 286N/A return fLocationPath.toString(); 286N/A /** Normalizes text. */ 286N/A }
// normalize(String):String 286N/A // NOTE: The main of this class is here for debugging purposes. 286N/A // However, javac (JDK 1.1.8) has an internal compiler 286N/A // error when compiling. Jikes has no problem, though. 286N/A // If you want to use this main, use Jikes to compile but 286N/A // *never* check in this code to CVS without commenting it 286N/A public static void main(String[] argv) throws XNIException { 286N/A for (int i = 0; i < argv.length; i++) { 286N/A final String expr = argv[i]; 286N/A final XPath xpath = new XPath(expr, symbols, null); 286N/A final XPathMatcher matcher = new XPathMatcher(xpath, true); 286N/A com.sun.org.apache.xerces.internal.parsers.SAXParser parser = 286N/A new com.sun.org.apache.xerces.internal.parsers.SAXParser(symbols) { 286N/A public void startDocument() throws XNIException { 286N/A matcher.startDocumentFragment(symbols, null); 286N/A public void startElement(QName element, XMLAttrList attributes, int handle) throws XNIException { 286N/A matcher.startElement(element, attributes, handle); 286N/A public void characters(char[] ch, int offset, int length) throws XNIException { 286N/A matcher.characters(ch, offset, length); 286N/A public void endElement(QName element) throws XNIException { 286N/A matcher.endElement(element); 286N/A public void endDocument() throws XNIException { 286N/A matcher.endDocumentFragment(); 286N/A System.out.println("#### argv["+i+"]: \""+expr+"\" -> \""+xpath.toString()+'"'); 286N/A final String uri = argv[++i]; 286N/A System.out.println("#### argv["+i+"]: "+uri);