286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * The Apache Software License, Version 1.1
286N/A *
286N/A *
286N/A * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
286N/A * reserved.
286N/A *
286N/A * Redistribution and use in source and binary forms, with or without
286N/A * modification, are permitted provided that the following conditions
286N/A * are met:
286N/A *
286N/A * 1. Redistributions of source code must retain the above copyright
286N/A * notice, this list of conditions and the following disclaimer.
286N/A *
286N/A * 2. Redistributions in binary form must reproduce the above copyright
286N/A * notice, this list of conditions and the following disclaimer in
286N/A * the documentation and/or other materials provided with the
286N/A * distribution.
286N/A *
286N/A * 3. The end-user documentation included with the redistribution,
286N/A * if any, must include the following acknowledgment:
286N/A * "This product includes software developed by the
286N/A * Apache Software Foundation (http://www.apache.org/)."
286N/A * Alternately, this acknowledgment may appear in the software itself,
286N/A * if and wherever such third-party acknowledgments normally appear.
286N/A *
286N/A * 4. The names "Xerces" and "Apache Software Foundation" must
286N/A * not be used to endorse or promote products derived from this
286N/A * software without prior written permission. For written
286N/A * permission, please contact apache@apache.org.
286N/A *
286N/A * 5. Products derived from this software may not be called "Apache",
286N/A * nor may "Apache" appear in their name, without prior written
286N/A * permission of the Apache Software Foundation.
286N/A *
286N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
286N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
286N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
286N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
286N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
286N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
286N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
286N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
286N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
286N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
286N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
286N/A * SUCH DAMAGE.
286N/A * ====================================================================
286N/A *
286N/A * This software consists of voluntary contributions made by many
286N/A * individuals on behalf of the Apache Software Foundation and was
286N/A * originally based on software copyright (c) 1999, International
286N/A * Business Machines, Inc., http://www.apache.org. For more
286N/A * information on the Apache Software Foundation, please see
286N/A * <http://www.apache.org/>.
286N/A */
286N/Apackage com.sun.org.apache.xerces.internal.xinclude;
286N/A
286N/A
286N/Aimport java.util.Enumeration;
286N/Aimport java.util.StringTokenizer;
286N/Aimport java.util.Stack;
286N/A
286N/Aimport com.sun.org.apache.xerces.internal.impl.Constants;
286N/Aimport com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
286N/Aimport com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
286N/Aimport com.sun.org.apache.xerces.internal.xni.Augmentations;
286N/Aimport com.sun.org.apache.xerces.internal.xni.NamespaceContext;
286N/Aimport com.sun.org.apache.xerces.internal.xni.QName;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLAttributes;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLLocator;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XMLString;
286N/Aimport com.sun.org.apache.xerces.internal.xni.XNIException;
286N/Aimport com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
286N/Aimport com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
286N/Aimport com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
286N/Aimport com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;
286N/A/**
286N/A * @author Arun Yadav, Sun Microsystem
286N/A */
286N/Apublic class XPointerElementHandler implements XPointerSchema {
286N/A
286N/A
286N/A // recognized features and properties
286N/A
286N/A /** Property identifier: error handler. */
286N/A protected static final String ERROR_REPORTER =
286N/A Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
286N/A
286N/A /** Property identifier: grammar pool . */
286N/A protected static final String GRAMMAR_POOL =
286N/A Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
286N/A
286N/A /** Property identifier: grammar pool . */
286N/A protected static final String ENTITY_RESOLVER =
286N/A Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
286N/A
286N/A protected static final String XPOINTER_SCHEMA =
286N/A Constants.XERCES_PROPERTY_PREFIX + Constants.XPOINTER_SCHEMA_PROPERTY;
286N/A
286N/A /** Recognized features. */
286N/A private static final String[] RECOGNIZED_FEATURES = {
286N/A };
286N/A
286N/A /** Feature defaults. */
286N/A private static final Boolean[] FEATURE_DEFAULTS = {
286N/A };
286N/A
286N/A /** Recognized properties. */
286N/A
286N/A private static final String[] RECOGNIZED_PROPERTIES =
286N/A { ERROR_REPORTER, GRAMMAR_POOL, ENTITY_RESOLVER, XPOINTER_SCHEMA };
286N/A
286N/A /** Property defaults. */
286N/A private static final Object[] PROPERTY_DEFAULTS = { null, null, null,null };
286N/A
286N/A // Data
286N/A
286N/A protected XMLDocumentHandler fDocumentHandler;
286N/A protected XMLDocumentSource fDocumentSource;
286N/A
286N/A protected XIncludeHandler fParentXIncludeHandler;
286N/A
286N/A protected XMLLocator fDocLocation;
286N/A protected XIncludeNamespaceSupport fNamespaceContext;
286N/A protected XMLErrorReporter fErrorReporter;
286N/A protected XMLGrammarPool fGrammarPool;
286N/A protected XMLGrammarDescription fGrammarDesc;
286N/A protected DTDGrammar fDTDGrammar;
286N/A protected XMLEntityResolver fEntityResolver;
286N/A protected ParserConfigurationSettings fSettings;
286N/A //protected String fPointerSchema;
286N/A protected StringBuffer fPointer;
286N/A private int elemCount = 0;
286N/A
286N/A
286N/A // The current element depth.
286N/A // This is used to access the appropriate level of the following stacks.
286N/A private int fDepth;
286N/A
286N/A // The depth of the first element to actually be part of the result infoset.
286N/A // This will normally be 1, but it could be larger when the top-level item
286N/A // is an include, and processing goes to the fallback.
286N/A private int fRootDepth;
286N/A
286N/A // this value must be at least 1
286N/A private static final int INITIAL_SIZE = 8;
286N/A
286N/A
286N/A // Used to ensure that fallbacks are always children of include elements,
286N/A // and that include elements are never children of other include elements.
286N/A // An index contains true if the ancestor of the current element which resides
286N/A // at that depth was an include element.
286N/A private boolean[] fSawInclude = new boolean[INITIAL_SIZE];
286N/A
286N/A
286N/A // Ensures that only one fallback element can be at a single depth.
286N/A // An index contains true if we have seen any fallback elements at that depth,
286N/A // and it is only reset to false when the end tag of the parent is encountered.
286N/A private boolean[] fSawFallback = new boolean[INITIAL_SIZE];
286N/A
286N/A
286N/A // The state of the processor at each given depth.
286N/A private int[] fState = new int[INITIAL_SIZE];
286N/A
286N/A QName foundElement = null;
286N/A boolean skip = false;
286N/A // Constructors
286N/A
286N/A public XPointerElementHandler() {
286N/A
286N/A
286N/A fDepth = 0;
286N/A fRootDepth = 0;
286N/A fSawFallback[fDepth] = false;
286N/A fSawInclude[fDepth] = false;
286N/A fSchemaName="element";
286N/A
286N/A
286N/A }
286N/A
286N/A // START OF IMPLEMENTATION OF XMLComponent methods //////
286N/A
286N/A public void reset(){
286N/A elemCount =0;
286N/A fPointerToken = null;
286N/A fCurrentTokenint=0;
286N/A fCurrentTokenString=null;
286N/A fCurrentTokenType=0 ;
286N/A fElementCount =0;
286N/A fCurrentToken =0;
286N/A includeElement = false;
286N/A foundElement = null;
286N/A skip = false;
286N/A fSubResourceIdentified=false;
286N/A }
286N/A
286N/A public void reset(XMLComponentManager componentManager)
286N/A throws XNIException {
286N/A fNamespaceContext = null;
286N/A elemCount =0;
286N/A fDepth = 0;
286N/A fRootDepth = 0;
286N/A fPointerToken = null;
286N/A fCurrentTokenint=0;
286N/A fCurrentTokenString=null;
286N/A fCurrentTokenType=0 ;
286N/A foundElement = null;
286N/A includeElement = false;
286N/A skip = false;
286N/A fSubResourceIdentified=false;
286N/A
286N/A
286N/A
286N/A
286N/A try {
286N/A setErrorReporter(
286N/A (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER));
286N/A }
286N/A catch (XMLConfigurationException e) {
286N/A fErrorReporter = null;
286N/A }
286N/A try {
286N/A fGrammarPool =
286N/A (XMLGrammarPool)componentManager.getProperty(GRAMMAR_POOL);
286N/A }
286N/A catch (XMLConfigurationException e) {
286N/A fGrammarPool = null;
286N/A }
286N/A try {
286N/A fEntityResolver =
286N/A (XMLEntityResolver)componentManager.getProperty(
286N/A ENTITY_RESOLVER);
286N/A }
286N/A catch (XMLConfigurationException e) {
286N/A fEntityResolver = null;
286N/A }
286N/A
286N/A fSettings = new ParserConfigurationSettings();
286N/A
286N/A Enumeration xercesFeatures = Constants.getXercesFeatures();
286N/A while (xercesFeatures.hasMoreElements()) {
286N/A String featureId = (String)xercesFeatures.nextElement();
286N/A fSettings.addRecognizedFeatures(new String[] { featureId });
286N/A try {
286N/A fSettings.setFeature(
286N/A featureId,
286N/A componentManager.getFeature(featureId));
286N/A }
286N/A catch (XMLConfigurationException e) {
286N/A // componentManager doesn't support this feature,
286N/A // so we won't worry about it
286N/A }
286N/A }
286N/A/* try{
286N/A dtdValidator = (XMLDTDValidator)componentManager.getProperty( Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY);
286N/A }Catch(Exception ex){
286N/A ex.printStackTrace();
286N/A }*/
286N/A
286N/A } // reset(XMLComponentManager)
286N/A
286N/A /**
286N/A * Returns a list of feature identifiers that are recognized by
286N/A * this component. This method may return null if no features
286N/A * are recognized by this component.
286N/A */
286N/A public String[] getRecognizedFeatures() {
286N/A return RECOGNIZED_FEATURES;
286N/A } // getRecognizedFeatures():String[]
286N/A
286N/A /**
286N/A * Sets the state of a feature. This method is called by the component
286N/A * manager any time after reset when a feature changes state.
286N/A * <p>
286N/A * <strong>Note:</strong> Components should silently ignore features
286N/A * that do not affect the operation of the component.
286N/A *
286N/A * @param featureId The feature identifier.
286N/A * @param state The state of the feature.
286N/A *
286N/A * @throws SAXNotRecognizedException The component should not throw
286N/A * this exception.
286N/A * @throws SAXNotSupportedException The component should not throw
286N/A * this exception.
286N/A */
286N/A public void setFeature(String featureId, boolean state)
286N/A throws XMLConfigurationException {
286N/A if (fSettings != null) {
286N/A fSettings.setFeature(featureId, state);
286N/A }
286N/A
286N/A } // setFeature(String,boolean)
286N/A
286N/A /**
286N/A * Returns a list of property identifiers that are recognized by
286N/A * this component. This method may return null if no properties
286N/A * are recognized by this component.
286N/A */
286N/A public String[] getRecognizedProperties() {
286N/A return RECOGNIZED_PROPERTIES;
286N/A } // getRecognizedProperties():String[]
286N/A
286N/A /**
286N/A * Sets the value of a property. This method is called by the component
286N/A * manager any time after reset when a property changes value.
286N/A * <p>
286N/A * <strong>Note:</strong> Components should silently ignore properties
286N/A * that do not affect the operation of the component.
286N/A *
286N/A * @param propertyId The property identifier.
286N/A * @param value The value of the property.
286N/A *
286N/A * @throws SAXNotRecognizedException The component should not throw
286N/A * this exception.
286N/A * @throws SAXNotSupportedException The component should not throw
286N/A * this exception.
286N/A */
286N/A public void setProperty(String propertyId, Object value)
286N/A throws XMLConfigurationException {
286N/A if (propertyId.equals(ERROR_REPORTER)) {
286N/A setErrorReporter((XMLErrorReporter)value);
286N/A }
286N/A if (propertyId.equals(GRAMMAR_POOL)) {
286N/A fGrammarPool = (XMLGrammarPool)value;
286N/A }
286N/A if (propertyId.equals(ENTITY_RESOLVER)) {
286N/A fEntityResolver = (XMLEntityResolver)value;
286N/A }
286N/A
286N/A } // setProperty(String,Object)
286N/A
286N/A /**
286N/A * Returns the default state for a feature, or null if this
286N/A * component does not want to report a default value for this
286N/A * feature.
286N/A *
286N/A * @param featureId The feature identifier.
286N/A *
286N/A * @since Xerces 2.2.0
286N/A */
286N/A public Boolean getFeatureDefault(String featureId) {
286N/A for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
286N/A if (RECOGNIZED_FEATURES[i].equals(featureId)) {
286N/A return FEATURE_DEFAULTS[i];
286N/A }
286N/A }
286N/A return null;
286N/A } // getFeatureDefault(String):Boolean
286N/A
286N/A /**
286N/A * Returns the default state for a property, or null if this
286N/A * component does not want to report a default value for this
286N/A * property.
286N/A *
286N/A * @param propertyId The property identifier.
286N/A *
286N/A * @since Xerces 2.2.0
286N/A */
286N/A public Object getPropertyDefault(String propertyId) {
286N/A for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
286N/A if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
286N/A return PROPERTY_DEFAULTS[i];
286N/A }
286N/A }
286N/A return null;
286N/A } // getPropertyDefault(String):Object
286N/A
286N/A private void setErrorReporter(XMLErrorReporter reporter) {
286N/A fErrorReporter = reporter;
286N/A if (fErrorReporter != null) {
286N/A fErrorReporter.putMessageFormatter(
286N/A XIncludeMessageFormatter.XINCLUDE_DOMAIN,
286N/A new XIncludeMessageFormatter());
286N/A }
286N/A }
286N/A ///////// END OF IMPLEMENTATION OF XMLComponents methods. //////////
286N/A
286N/A
286N/A
286N/A //////// START OF IMPLEMENTATION OF XMLDOCUMENTSOURCE INTERFACE /////////
286N/A
286N/A public void setDocumentHandler(XMLDocumentHandler handler) {
286N/A fDocumentHandler = handler;
286N/A }
286N/A
286N/A public XMLDocumentHandler getDocumentHandler() {
286N/A return fDocumentHandler;
286N/A }
286N/A
286N/A /////// END OF IMPLENTATION OF XMLDOCUMENTSOURCE INTERFACE ///////////
286N/A
286N/A
286N/A
286N/A
286N/A /////////////// Implementation of XPointerSchema Methods //////////////////////
286N/A
286N/A String fSchemaName;
286N/A String fSchemaPointer;
286N/A boolean fSubResourceIdentified;
286N/A /**
286N/A * set the Schema Name eg element , xpointer
286N/A */
286N/A public void setXPointerSchemaName(String schemaName){
286N/A fSchemaName = schemaName;
286N/A }
286N/A
286N/A /**
286N/A * Return Schema Name eg element , xpointer
286N/A *
286N/A */
286N/A public String getXpointerSchemaName(){
286N/A return fSchemaName;
286N/A }
286N/A
286N/A /**
286N/A * Parent Contenhandler for the this contenthandler.
286N/A * // not sure about the parameter type. It can be Contenthandler instead of Object type.
286N/A */
286N/A public void setParent(Object parent){
286N/A fParentXIncludeHandler = (XIncludeHandler)parent;
286N/A }
286N/A
286N/A
286N/A /**
286N/A * return the Parent Contenthandler
286N/A */
286N/A public Object getParent(){
286N/A return fParentXIncludeHandler;
286N/A }
286N/A
286N/A /**
286N/A * Content of the XPointer Schema. Xpath to be resolved.
286N/A */
286N/A public void setXPointerSchemaPointer(String content){
286N/A fSchemaPointer = content;
286N/A }
286N/A
286N/A /**
286N/A * Return the XPointer Schema.
286N/A */
286N/A public String getXPointerSchemaPointer(){
286N/A return fSchemaPointer;
286N/A }
286N/A
286N/A public boolean isSubResourceIndentified(){
286N/A return fSubResourceIdentified;
286N/A }
286N/A
286N/A ///////////End Implementation of XPointerSchema Methods //////////////////////
286N/A
286N/A
286N/A
286N/A //////////// Tokens Playground ///////////////////
286N/A
286N/A Stack fPointerToken = new Stack();
286N/A int fCurrentTokenint=0;
286N/A String fCurrentTokenString=null;
286N/A int fCurrentTokenType=0 ;// 0 Notype; 1 for integer; 2 for string.
286N/A
286N/A public void getTokens(){
286N/A fSchemaPointer = fSchemaPointer.substring(fSchemaPointer.indexOf("(")+1, fSchemaPointer.length());
286N/A StringTokenizer st = new StringTokenizer(fSchemaPointer, "/");
286N/A String tempToken;
286N/A Integer integerToken =null;
286N/A Stack tempPointerToken = new Stack();
286N/A if(fPointerToken == null){
286N/A fPointerToken = new Stack();
286N/A }
286N/A while(st.hasMoreTokens()){
286N/A tempToken=st.nextToken();
286N/A try {
286N/A integerToken = Integer.valueOf(tempToken);
286N/A tempPointerToken.push(integerToken);
286N/A }catch(NumberFormatException e){
286N/A tempPointerToken.push(tempToken);
286N/A }
286N/A }
286N/A while(!tempPointerToken.empty()){
286N/A fPointerToken.push(tempPointerToken.pop());
286N/A }
286N/A }//getTokens
286N/A
286N/A
286N/A public boolean hasMoreToken(){
286N/A if(fPointerToken.isEmpty())
286N/A return false;
286N/A else
286N/A return true;
286N/A }
286N/A
286N/A public boolean getNextToken(){
286N/A Object currentToken;
286N/A if (!fPointerToken.isEmpty()){
286N/A currentToken = fPointerToken.pop();
286N/A if(currentToken instanceof Integer){
286N/A fCurrentTokenint = ((Integer)currentToken).intValue();
286N/A fCurrentTokenType = 1;
286N/A }
286N/A else{
286N/A fCurrentTokenString = ((String)currentToken).toString();
286N/A fCurrentTokenType = 2;
286N/A }
286N/A return true;
286N/A }
286N/A else {
286N/A return false;
286N/A }
286N/A }
286N/A
286N/A private boolean isIdAttribute(XMLAttributes attributes,Augmentations augs, int index) {
286N/A Object o = augs.getItem(Constants.ID_ATTRIBUTE);
286N/A if( o instanceof Boolean )
286N/A return ((Boolean)o).booleanValue();
286N/A return "ID".equals(attributes.getType(index));
286N/A }
286N/A
286N/A public boolean checkStringToken(QName element, XMLAttributes attributes){
286N/A QName cacheQName = null;
286N/A String id =null;
286N/A String rawname =null;
286N/A QName attrName = new QName();
286N/A String attrType = null;
286N/A String attrValue = null;
286N/A int attrCount = attributes.getLength();
286N/A for (int i = 0; i < attrCount; i++) {
286N/A Augmentations aaugs = attributes.getAugmentations(i);
286N/A attributes.getName(i,attrName);
286N/A attrType = attributes.getType(i);
286N/A attrValue = attributes.getValue(i);
286N/A if(attrType != null && attrValue!= null && isIdAttribute(attributes,aaugs,i) && attrValue.equals(fCurrentTokenString)){
286N/A if(hasMoreToken()){
286N/A fCurrentTokenType = 0;
286N/A fCurrentTokenString = null;
286N/A return true;
286N/A }
286N/A else{
286N/A foundElement = element;
286N/A includeElement = true;
286N/A fCurrentTokenType = 0;
286N/A fCurrentTokenString = null;
286N/A fSubResourceIdentified = true;
286N/A return true;
286N/A }
286N/A }
286N/A }
286N/A return false;
286N/A }
286N/A
286N/A public boolean checkIntegerToken(QName element){
286N/A if(!skip){
286N/A fElementCount++;
286N/A if(fCurrentTokenint == fElementCount){
286N/A if(hasMoreToken()){
286N/A fElementCount=0;
286N/A fCurrentTokenType = 0;
286N/A return true;
286N/A }
286N/A else{
286N/A foundElement = element;
286N/A includeElement = true;
286N/A fCurrentTokenType = 0;
286N/A fElementCount=0;
286N/A fSubResourceIdentified =true;
286N/A return true;
286N/A }
286N/A }else{
286N/A addQName(element);
286N/A skip = true;
286N/A return false;
286N/A }
286N/A }
286N/A return false;
286N/A }
286N/A
286N/A public void addQName(QName element){
286N/A QName cacheQName = new QName(element);
286N/A ftempCurrentElement.push(cacheQName);
286N/A }
286N/A
286N/A /////////// END TOKEN PLAYGROUND ///////////////
286N/A
286N/A
286N/A ///// START OF IMPLEMTATION OF XMLDocumentHandler methods //////////
286N/A
286N/A
286N/A public void startDocument(XMLLocator locator, String encoding,
286N/A NamespaceContext namespaceContext, Augmentations augs)
286N/A throws XNIException {
286N/A
286N/A getTokens();
286N/A }
286N/A
286N/A public void doctypeDecl(String rootElement, String publicId, String systemId,
286N/A Augmentations augs)throws XNIException {
286N/A }
286N/A
286N/A public void xmlDecl(String version, String encoding, String standalone,
286N/A Augmentations augs) throws XNIException {
286N/A }
286N/A
286N/A
286N/A public void comment(XMLString text, Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.comment(text, augs);
286N/A }
286N/A }
286N/A
286N/A public void processingInstruction(String target, XMLString data,
286N/A Augmentations augs) throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.processingInstruction(target, data, augs);
286N/A
286N/A }
286N/A }
286N/A
286N/A Stack ftempCurrentElement = new Stack();
286N/A int fElementCount =0;
286N/A int fCurrentToken ;
286N/A boolean includeElement;
286N/A
286N/A
286N/A public void startElement(QName element, XMLAttributes attributes,
286N/A Augmentations augs)throws XNIException {
286N/A
286N/A boolean requiredToken=false;
286N/A if(fCurrentTokenType == 0)
286N/A getNextToken();
286N/A if(fCurrentTokenType ==1)
286N/A requiredToken = checkIntegerToken(element);
286N/A else if (fCurrentTokenType ==2)
286N/A requiredToken = checkStringToken(element, attributes);
286N/A if(requiredToken && hasMoreToken())
286N/A getNextToken();
286N/A if(fDocumentHandler != null && includeElement){
286N/A elemCount++;
286N/A fDocumentHandler.startElement(element, attributes, augs);
286N/A }
286N/A
286N/A }
286N/A
286N/A
286N/A public void endElement(QName element, Augmentations augs)
286N/A throws XNIException {
286N/A if(includeElement && foundElement != null ){
286N/A if(elemCount >0 )elemCount --;
286N/A fDocumentHandler.endElement(element, augs);
286N/A if(elemCount == 0)includeElement = false;
286N/A
286N/A }else if(!ftempCurrentElement.empty()){
286N/A QName name = (QName)ftempCurrentElement.peek();
286N/A if(name.equals(element)){
286N/A ftempCurrentElement.pop();
286N/A skip = false;
286N/A }
286N/A }
286N/A }
286N/A
286N/A public void emptyElement(QName element, XMLAttributes attributes,
286N/A Augmentations augs)throws XNIException {
286N/A if(fDocumentHandler != null && includeElement){
286N/A fDocumentHandler.emptyElement(element, attributes, augs);
286N/A }
286N/A }
286N/A
286N/A public void startGeneralEntity(String name, XMLResourceIdentifier resId,
286N/A String encoding,
286N/A Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.startGeneralEntity(name, resId, encoding, augs);
286N/A }
286N/A }
286N/A
286N/A public void textDecl(String version, String encoding, Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.textDecl(version, encoding, augs);
286N/A }
286N/A }
286N/A
286N/A public void endGeneralEntity(String name, Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null) {
286N/A fDocumentHandler.endGeneralEntity(name, augs);
286N/A }
286N/A }
286N/A
286N/A public void characters(XMLString text, Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.characters(text, augs);
286N/A }
286N/A }
286N/A
286N/A public void ignorableWhitespace(XMLString text, Augmentations augs)
286N/A throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.ignorableWhitespace(text, augs);
286N/A }
286N/A }
286N/A
286N/A public void startCDATA(Augmentations augs) throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.startCDATA(augs);
286N/A }
286N/A }
286N/A
286N/A public void endCDATA(Augmentations augs) throws XNIException {
286N/A if (fDocumentHandler != null && includeElement) {
286N/A fDocumentHandler.endCDATA(augs);
286N/A }
286N/A }
286N/A
286N/A public void endDocument(Augmentations augs) throws XNIException {
286N/A }
286N/A
286N/A public void setDocumentSource(XMLDocumentSource source) {
286N/A fDocumentSource = source;
286N/A }
286N/A
286N/A public XMLDocumentSource getDocumentSource() {
286N/A return fDocumentSource;
286N/A }
286N/A
286N/A
286N/A protected void reportFatalError(String key) {
286N/A this.reportFatalError(key, null);
286N/A }
286N/A
286N/A protected void reportFatalError(String key, Object[] args) {
286N/A if (fErrorReporter != null) {
286N/A fErrorReporter.reportError(
286N/A fDocLocation,
286N/A XIncludeMessageFormatter.XINCLUDE_DOMAIN,
286N/A key,
286N/A args,
286N/A XMLErrorReporter.SEVERITY_FATAL_ERROR);
286N/A }
286N/A // we won't worry about when error reporter is null, since there should always be
286N/A // at least the default error reporter
286N/A }
286N/A
286N/A
286N/A
286N/A // used to know whether to pass declarations to the document handler
286N/A protected boolean isRootDocument() {
286N/A return this.fParentXIncludeHandler == null;
286N/A }
286N/A
286N/A
286N/A} // class XPointerElementhandler