KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > xinclude > XPointerElementHandler


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 1999, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57 package com.sun.org.apache.xerces.internal.xinclude;
58
59
60 import java.util.Enumeration JavaDoc;
61 import java.util.StringTokenizer JavaDoc;
62 import java.util.Stack JavaDoc;
63
64 import com.sun.org.apache.xerces.internal.impl.Constants;
65 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
66 import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
67 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
68 import com.sun.org.apache.xerces.internal.xni.Augmentations;
69 import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
70 import com.sun.org.apache.xerces.internal.xni.QName;
71 import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
72 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
73 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
74 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
75 import com.sun.org.apache.xerces.internal.xni.XMLString;
76 import com.sun.org.apache.xerces.internal.xni.XNIException;
77 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
78 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
79 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
80 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
81 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
82 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
83 import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;
84 /**
85  * @author Arun Yadav, Sun Microsystem
86  */

87 public class XPointerElementHandler implements XPointerSchema {
88     
89     
90     // recognized features and properties
91

92     /** Property identifier: error handler. */
93     protected static final String JavaDoc ERROR_REPORTER =
94     Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
95     
96     /** Property identifier: grammar pool . */
97     protected static final String JavaDoc GRAMMAR_POOL =
98     Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
99     
100     /** Property identifier: grammar pool . */
101     protected static final String JavaDoc ENTITY_RESOLVER =
102     Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
103     
104     protected static final String JavaDoc XPOINTER_SCHEMA =
105     Constants.XERCES_PROPERTY_PREFIX + Constants.XPOINTER_SCHEMA_PROPERTY;
106     
107     /** Recognized features. */
108     private static final String JavaDoc[] RECOGNIZED_FEATURES = {
109     };
110     
111     /** Feature defaults. */
112     private static final Boolean JavaDoc[] FEATURE_DEFAULTS = {
113     };
114     
115     /** Recognized properties. */
116     
117     private static final String JavaDoc[] RECOGNIZED_PROPERTIES =
118     { ERROR_REPORTER, GRAMMAR_POOL, ENTITY_RESOLVER, XPOINTER_SCHEMA };
119     
120     /** Property defaults. */
121     private static final Object JavaDoc[] PROPERTY_DEFAULTS = { null, null, null,null };
122     
123     // Data
124

125     protected XMLDocumentHandler fDocumentHandler;
126     protected XMLDocumentSource fDocumentSource;
127     
128     protected XIncludeHandler fParentXIncludeHandler;
129     
130     protected XMLLocator fDocLocation;
131     protected XIncludeNamespaceSupport fNamespaceContext;
132     protected XMLErrorReporter fErrorReporter;
133     protected XMLGrammarPool fGrammarPool;
134     protected XMLGrammarDescription fGrammarDesc;
135     protected DTDGrammar fDTDGrammar;
136     protected XMLEntityResolver fEntityResolver;
137     protected ParserConfigurationSettings fSettings;
138     //protected String fPointerSchema;
139
protected StringBuffer JavaDoc fPointer;
140     private int elemCount = 0;
141     
142     
143     // The current element depth.
144
// This is used to access the appropriate level of the following stacks.
145
private int fDepth;
146     
147     // The depth of the first element to actually be part of the result infoset.
148
// This will normally be 1, but it could be larger when the top-level item
149
// is an include, and processing goes to the fallback.
150
private int fRootDepth;
151     
152     // this value must be at least 1
153
private static final int INITIAL_SIZE = 8;
154     
155     
156     // Used to ensure that fallbacks are always children of include elements,
157
// and that include elements are never children of other include elements.
158
// An index contains true if the ancestor of the current element which resides
159
// at that depth was an include element.
160
private boolean[] fSawInclude = new boolean[INITIAL_SIZE];
161     
162     
163     // Ensures that only one fallback element can be at a single depth.
164
// An index contains true if we have seen any fallback elements at that depth,
165
// and it is only reset to false when the end tag of the parent is encountered.
166
private boolean[] fSawFallback = new boolean[INITIAL_SIZE];
167     
168     
169     // The state of the processor at each given depth.
170
private int[] fState = new int[INITIAL_SIZE];
171     
172     QName foundElement = null;
173     boolean skip = false;
174     // Constructors
175

176     public XPointerElementHandler() {
177         
178         
179         fDepth = 0;
180         fRootDepth = 0;
181         fSawFallback[fDepth] = false;
182         fSawInclude[fDepth] = false;
183         fSchemaName="element";
184         
185         
186     }
187     
188     // START OF IMPLEMENTATION OF XMLComponent methods //////
189

190     public void reset(){
191         elemCount =0;
192         fPointerToken = null;
193         fCurrentTokenint=0;
194         fCurrentTokenString=null;
195         fCurrentTokenType=0 ;
196         fElementCount =0;
197         fCurrentToken =0;
198         includeElement = false;
199         foundElement = null;
200         skip = false;
201         fSubResourceIdentified=false;
202     }
203     
204     public void reset(XMLComponentManager componentManager)
205     throws XNIException {
206         fNamespaceContext = null;
207         elemCount =0;
208         fDepth = 0;
209         fRootDepth = 0;
210         fPointerToken = null;
211         fCurrentTokenint=0;
212         fCurrentTokenString=null;
213         fCurrentTokenType=0 ;
214         foundElement = null;
215         includeElement = false;
216         skip = false;
217         fSubResourceIdentified=false;
218         
219         
220         
221         
222         try {
223             setErrorReporter(
224             (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER));
225         }
226         catch (XMLConfigurationException e) {
227             fErrorReporter = null;
228         }
229         try {
230             fGrammarPool =
231             (XMLGrammarPool)componentManager.getProperty(GRAMMAR_POOL);
232         }
233         catch (XMLConfigurationException e) {
234             fGrammarPool = null;
235         }
236         try {
237             fEntityResolver =
238             (XMLEntityResolver)componentManager.getProperty(
239             ENTITY_RESOLVER);
240         }
241         catch (XMLConfigurationException e) {
242             fEntityResolver = null;
243         }
244         
245         fSettings = new ParserConfigurationSettings();
246         
247         Enumeration JavaDoc xercesFeatures = Constants.getXercesFeatures();
248         while (xercesFeatures.hasMoreElements()) {
249             String JavaDoc featureId = (String JavaDoc)xercesFeatures.nextElement();
250             fSettings.addRecognizedFeatures(new String JavaDoc[] { featureId });
251             try {
252                 fSettings.setFeature(
253                 featureId,
254                 componentManager.getFeature(featureId));
255             }
256             catch (XMLConfigurationException e) {
257                 // componentManager doesn't support this feature,
258
// so we won't worry about it
259
}
260         }
261 /* try{
262           dtdValidator = (XMLDTDValidator)componentManager.getProperty( Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY);
263                 }Catch(Exception ex){
264                         ex.printStackTrace();
265                 }*/

266         
267     } // reset(XMLComponentManager)
268

269     /**
270      * Returns a list of feature identifiers that are recognized by
271      * this component. This method may return null if no features
272      * are recognized by this component.
273      */

274     public String JavaDoc[] getRecognizedFeatures() {
275         return RECOGNIZED_FEATURES;
276     } // getRecognizedFeatures():String[]
277

278     /**
279      * Sets the state of a feature. This method is called by the component
280      * manager any time after reset when a feature changes state.
281      * <p>
282      * <strong>Note:</strong> Components should silently ignore features
283      * that do not affect the operation of the component.
284      *
285      * @param featureId The feature identifier.
286      * @param state The state of the feature.
287      *
288      * @throws SAXNotRecognizedException The component should not throw
289      * this exception.
290      * @throws SAXNotSupportedException The component should not throw
291      * this exception.
292      */

293     public void setFeature(String JavaDoc featureId, boolean state)
294     throws XMLConfigurationException {
295         if (fSettings != null) {
296             fSettings.setFeature(featureId, state);
297         }
298         
299     } // setFeature(String,boolean)
300

301     /**
302      * Returns a list of property identifiers that are recognized by
303      * this component. This method may return null if no properties
304      * are recognized by this component.
305      */

306     public String JavaDoc[] getRecognizedProperties() {
307         return RECOGNIZED_PROPERTIES;
308     } // getRecognizedProperties():String[]
309

310     /**
311      * Sets the value of a property. This method is called by the component
312      * manager any time after reset when a property changes value.
313      * <p>
314      * <strong>Note:</strong> Components should silently ignore properties
315      * that do not affect the operation of the component.
316      *
317      * @param propertyId The property identifier.
318      * @param value The value of the property.
319      *
320      * @throws SAXNotRecognizedException The component should not throw
321      * this exception.
322      * @throws SAXNotSupportedException The component should not throw
323      * this exception.
324      */

325     public void setProperty(String JavaDoc propertyId, Object JavaDoc value)
326     throws XMLConfigurationException {
327         if (propertyId.equals(ERROR_REPORTER)) {
328             setErrorReporter((XMLErrorReporter)value);
329         }
330         if (propertyId.equals(GRAMMAR_POOL)) {
331             fGrammarPool = (XMLGrammarPool)value;
332         }
333         if (propertyId.equals(ENTITY_RESOLVER)) {
334             fEntityResolver = (XMLEntityResolver)value;
335         }
336         
337     } // setProperty(String,Object)
338

339     /**
340      * Returns the default state for a feature, or null if this
341      * component does not want to report a default value for this
342      * feature.
343      *
344      * @param featureId The feature identifier.
345      *
346      * @since Xerces 2.2.0
347      */

348     public Boolean JavaDoc getFeatureDefault(String JavaDoc featureId) {
349         for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
350             if (RECOGNIZED_FEATURES[i].equals(featureId)) {
351                 return FEATURE_DEFAULTS[i];
352             }
353         }
354         return null;
355     } // getFeatureDefault(String):Boolean
356

357     /**
358      * Returns the default state for a property, or null if this
359      * component does not want to report a default value for this
360      * property.
361      *
362      * @param propertyId The property identifier.
363      *
364      * @since Xerces 2.2.0
365      */

366     public Object JavaDoc getPropertyDefault(String JavaDoc propertyId) {
367         for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
368             if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
369                 return PROPERTY_DEFAULTS[i];
370             }
371         }
372         return null;
373     } // getPropertyDefault(String):Object
374

375     private void setErrorReporter(XMLErrorReporter reporter) {
376         fErrorReporter = reporter;
377         if (fErrorReporter != null) {
378             fErrorReporter.putMessageFormatter(
379             XIncludeMessageFormatter.XINCLUDE_DOMAIN,
380             new XIncludeMessageFormatter());
381         }
382     }
383     ///////// END OF IMPLEMENTATION OF XMLComponents methods. //////////
384

385     
386     
387     //////// START OF IMPLEMENTATION OF XMLDOCUMENTSOURCE INTERFACE /////////
388

389     public void setDocumentHandler(XMLDocumentHandler handler) {
390         fDocumentHandler = handler;
391     }
392     
393     public XMLDocumentHandler getDocumentHandler() {
394         return fDocumentHandler;
395     }
396     
397     /////// END OF IMPLENTATION OF XMLDOCUMENTSOURCE INTERFACE ///////////
398

399     
400     
401     
402     /////////////// Implementation of XPointerSchema Methods //////////////////////
403

404     String JavaDoc fSchemaName;
405     String JavaDoc fSchemaPointer;
406     boolean fSubResourceIdentified;
407     /**
408      * set the Schema Name eg element , xpointer
409      */

410     public void setXPointerSchemaName(String JavaDoc schemaName){
411         fSchemaName = schemaName;
412     }
413     
414     /**
415      * Return Schema Name eg element , xpointer
416      *
417      */

418     public String JavaDoc getXpointerSchemaName(){
419         return fSchemaName;
420     }
421     
422     /**
423      * Parent Contenhandler for the this contenthandler.
424      * // not sure about the parameter type. It can be Contenthandler instead of Object type.
425      */

426     public void setParent(Object JavaDoc parent){
427         fParentXIncludeHandler = (XIncludeHandler)parent;
428     }
429     
430     
431     /**
432      * return the Parent Contenthandler
433      */

434     public Object JavaDoc getParent(){
435         return fParentXIncludeHandler;
436     }
437     
438     /**
439      * Content of the XPointer Schema. Xpath to be resolved.
440      */

441     public void setXPointerSchemaPointer(String JavaDoc content){
442         fSchemaPointer = content;
443     }
444     
445     /**
446      * Return the XPointer Schema.
447      */

448     public String JavaDoc getXPointerSchemaPointer(){
449         return fSchemaPointer;
450     }
451     
452     public boolean isSubResourceIndentified(){
453         return fSubResourceIdentified;
454     }
455     
456     ///////////End Implementation of XPointerSchema Methods //////////////////////
457

458     
459     
460     //////////// Tokens Playground ///////////////////
461

462     Stack JavaDoc fPointerToken = new Stack JavaDoc();
463     int fCurrentTokenint=0;
464     String JavaDoc fCurrentTokenString=null;
465     int fCurrentTokenType=0 ;// 0 Notype; 1 for integer; 2 for string.
466

467     public void getTokens(){
468         fSchemaPointer = fSchemaPointer.substring(fSchemaPointer.indexOf("(")+1, fSchemaPointer.length());
469         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(fSchemaPointer, "/");
470         String JavaDoc tempToken;
471         Integer JavaDoc integerToken =null;
472         Stack JavaDoc tempPointerToken = new Stack JavaDoc();
473         if(fPointerToken == null){
474             fPointerToken = new Stack JavaDoc();
475         }
476         while(st.hasMoreTokens()){
477             tempToken=st.nextToken();
478             try {
479                 integerToken = Integer.valueOf(tempToken);
480                 tempPointerToken.push(integerToken);
481             }catch(NumberFormatException JavaDoc e){
482                 tempPointerToken.push(tempToken);
483             }
484         }
485         while(!tempPointerToken.empty()){
486             fPointerToken.push(tempPointerToken.pop());
487         }
488     }//getTokens
489

490     
491     public boolean hasMoreToken(){
492         if(fPointerToken.isEmpty())
493             return false;
494         else
495             return true;
496     }
497     
498     public boolean getNextToken(){
499         Object JavaDoc currentToken;
500         if (!fPointerToken.isEmpty()){
501             currentToken = fPointerToken.pop();
502             if(currentToken instanceof Integer JavaDoc){
503                 fCurrentTokenint = ((Integer JavaDoc)currentToken).intValue();
504                 fCurrentTokenType = 1;
505             }
506             else{
507                 fCurrentTokenString = ((String JavaDoc)currentToken).toString();
508                 fCurrentTokenType = 2;
509             }
510             return true;
511         }
512         else {
513             return false;
514         }
515     }
516     
517     private boolean isIdAttribute(XMLAttributes attributes,Augmentations augs, int index) {
518         Object JavaDoc o = augs.getItem(Constants.ID_ATTRIBUTE);
519         if( o instanceof Boolean JavaDoc )
520             return ((Boolean JavaDoc)o).booleanValue();
521         return "ID".equals(attributes.getType(index));
522     }
523     
524     public boolean checkStringToken(QName element, XMLAttributes attributes){
525         QName cacheQName = null;
526         String JavaDoc id =null;
527         String JavaDoc rawname =null;
528         QName attrName = new QName();
529         String JavaDoc attrType = null;
530         String JavaDoc attrValue = null;
531         int attrCount = attributes.getLength();
532         for (int i = 0; i < attrCount; i++) {
533             Augmentations aaugs = attributes.getAugmentations(i);
534             attributes.getName(i,attrName);
535             attrType = attributes.getType(i);
536             attrValue = attributes.getValue(i);
537             if(attrType != null && attrValue!= null && isIdAttribute(attributes,aaugs,i) && attrValue.equals(fCurrentTokenString)){
538                 if(hasMoreToken()){
539                     fCurrentTokenType = 0;
540                     fCurrentTokenString = null;
541                     return true;
542                 }
543                 else{
544                     foundElement = element;
545                     includeElement = true;
546                     fCurrentTokenType = 0;
547                     fCurrentTokenString = null;
548                     fSubResourceIdentified = true;
549                     return true;
550                 }
551             }
552         }
553         return false;
554     }
555     
556     public boolean checkIntegerToken(QName element){
557         if(!skip){
558             fElementCount++;
559             if(fCurrentTokenint == fElementCount){
560                 if(hasMoreToken()){
561                     fElementCount=0;
562                     fCurrentTokenType = 0;
563                     return true;
564                 }
565                 else{
566                     foundElement = element;
567                     includeElement = true;
568                     fCurrentTokenType = 0;
569                     fElementCount=0;
570                     fSubResourceIdentified =true;
571                     return true;
572                 }
573             }else{
574                 addQName(element);
575                 skip = true;
576                 return false;
577             }
578         }
579         return false;
580     }
581     
582     public void addQName(QName element){
583         QName cacheQName = new QName(element);
584         ftempCurrentElement.push(cacheQName);
585     }
586     
587     /////////// END TOKEN PLAYGROUND ///////////////
588

589     
590     ///// START OF IMPLEMTATION OF XMLDocumentHandler methods //////////
591

592     
593     public void startDocument(XMLLocator locator, String JavaDoc encoding,
594     NamespaceContext namespaceContext, Augmentations augs)
595     throws XNIException {
596         
597         getTokens();
598     }
599     
600     public void doctypeDecl(String JavaDoc rootElement, String JavaDoc publicId, String JavaDoc systemId,
601     Augmentations augs)throws XNIException {
602     }
603     
604     public void xmlDecl(String JavaDoc version, String JavaDoc encoding, String JavaDoc standalone,
605     Augmentations augs) throws XNIException {
606     }
607     
608     
609     public void comment(XMLString text, Augmentations augs)
610     throws XNIException {
611         if (fDocumentHandler != null && includeElement) {
612             fDocumentHandler.comment(text, augs);
613         }
614     }
615     
616     public void processingInstruction(String JavaDoc target, XMLString data,
617     Augmentations augs) throws XNIException {
618         if (fDocumentHandler != null && includeElement) {
619             fDocumentHandler.processingInstruction(target, data, augs);
620             
621         }
622     }
623     
624     Stack JavaDoc ftempCurrentElement = new Stack JavaDoc();
625     int fElementCount =0;
626     int fCurrentToken ;
627     boolean includeElement;
628     
629     
630     public void startElement(QName element, XMLAttributes attributes,
631     Augmentations augs)throws XNIException {
632         
633         boolean requiredToken=false;
634         if(fCurrentTokenType == 0)
635             getNextToken();
636         if(fCurrentTokenType ==1)
637             requiredToken = checkIntegerToken(element);
638         else if (fCurrentTokenType ==2)
639             requiredToken = checkStringToken(element, attributes);
640         if(requiredToken && hasMoreToken())
641             getNextToken();
642         if(fDocumentHandler != null && includeElement){
643             elemCount++;
644             fDocumentHandler.startElement(element, attributes, augs);
645         }
646         
647     }
648     
649     
650     public void endElement(QName element, Augmentations augs)
651     throws XNIException {
652         if(includeElement && foundElement != null ){
653             if(elemCount >0 )elemCount --;
654             fDocumentHandler.endElement(element, augs);
655             if(elemCount == 0)includeElement = false;
656             
657         }else if(!ftempCurrentElement.empty()){
658             QName name = (QName)ftempCurrentElement.peek();
659             if(name.equals(element)){
660                 ftempCurrentElement.pop();
661                 skip = false;
662             }
663         }
664     }
665     
666     public void emptyElement(QName element, XMLAttributes attributes,
667     Augmentations augs)throws XNIException {
668         if(fDocumentHandler != null && includeElement){
669             fDocumentHandler.emptyElement(element, attributes, augs);
670         }
671     }
672     
673     public void startGeneralEntity(String JavaDoc name, XMLResourceIdentifier resId,
674     String JavaDoc encoding,
675     Augmentations augs)
676     throws XNIException {
677         if (fDocumentHandler != null && includeElement) {
678             fDocumentHandler.startGeneralEntity(name, resId, encoding, augs);
679         }
680     }
681     
682     public void textDecl(String JavaDoc version, String JavaDoc encoding, Augmentations augs)
683     throws XNIException {
684         if (fDocumentHandler != null && includeElement) {
685             fDocumentHandler.textDecl(version, encoding, augs);
686         }
687     }
688     
689     public void endGeneralEntity(String JavaDoc name, Augmentations augs)
690     throws XNIException {
691         if (fDocumentHandler != null) {
692             fDocumentHandler.endGeneralEntity(name, augs);
693         }
694     }
695     
696     public void characters(XMLString text, Augmentations augs)
697     throws XNIException {
698         if (fDocumentHandler != null && includeElement) {
699             fDocumentHandler.characters(text, augs);
700         }
701     }
702     
703     public void ignorableWhitespace(XMLString text, Augmentations augs)
704     throws XNIException {
705         if (fDocumentHandler != null && includeElement) {
706             fDocumentHandler.ignorableWhitespace(text, augs);
707         }
708     }
709     
710     public void startCDATA(Augmentations augs) throws XNIException {
711         if (fDocumentHandler != null && includeElement) {
712             fDocumentHandler.startCDATA(augs);
713         }
714     }
715     
716     public void endCDATA(Augmentations augs) throws XNIException {
717         if (fDocumentHandler != null && includeElement) {
718             fDocumentHandler.endCDATA(augs);
719         }
720     }
721     
722     public void endDocument(Augmentations augs) throws XNIException {
723     }
724     
725     public void setDocumentSource(XMLDocumentSource source) {
726         fDocumentSource = source;
727     }
728     
729     public XMLDocumentSource getDocumentSource() {
730         return fDocumentSource;
731     }
732     
733     
734     protected void reportFatalError(String JavaDoc key) {
735         this.reportFatalError(key, null);
736     }
737     
738     protected void reportFatalError(String JavaDoc key, Object JavaDoc[] args) {
739         if (fErrorReporter != null) {
740             fErrorReporter.reportError(
741             fDocLocation,
742             XIncludeMessageFormatter.XINCLUDE_DOMAIN,
743             key,
744             args,
745             XMLErrorReporter.SEVERITY_FATAL_ERROR);
746         }
747         // we won't worry about when error reporter is null, since there should always be
748
// at least the default error reporter
749
}
750     
751     
752     
753     // used to know whether to pass declarations to the document handler
754
protected boolean isRootDocument() {
755         return this.fParentXIncludeHandler == null;
756     }
757     
758     
759 } // class XPointerElementhandler
760
Popular Tags