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. import java.util.Enumeration;
  59. import java.util.StringTokenizer;
  60. import java.util.Stack;
  61. import com.sun.org.apache.xerces.internal.impl.Constants;
  62. import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
  63. import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
  64. import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
  65. import com.sun.org.apache.xerces.internal.xni.Augmentations;
  66. import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
  67. import com.sun.org.apache.xerces.internal.xni.QName;
  68. import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
  69. import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  70. import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  71. import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
  72. import com.sun.org.apache.xerces.internal.xni.XMLString;
  73. import com.sun.org.apache.xerces.internal.xni.XNIException;
  74. import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
  75. import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool;
  76. import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
  77. import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  78. import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  79. import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  80. import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator;
  81. /**
  82. * @author Arun Yadav, Sun Microsystem
  83. */
  84. public class XPointerElementHandler implements XPointerSchema {
  85. // recognized features and properties
  86. /** Property identifier: error handler. */
  87. protected static final String ERROR_REPORTER =
  88. Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
  89. /** Property identifier: grammar pool . */
  90. protected static final String GRAMMAR_POOL =
  91. Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
  92. /** Property identifier: grammar pool . */
  93. protected static final String ENTITY_RESOLVER =
  94. Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
  95. protected static final String XPOINTER_SCHEMA =
  96. Constants.XERCES_PROPERTY_PREFIX + Constants.XPOINTER_SCHEMA_PROPERTY;
  97. /** Recognized features. */
  98. private static final String[] RECOGNIZED_FEATURES = {
  99. };
  100. /** Feature defaults. */
  101. private static final Boolean[] FEATURE_DEFAULTS = {
  102. };
  103. /** Recognized properties. */
  104. private static final String[] RECOGNIZED_PROPERTIES =
  105. { ERROR_REPORTER, GRAMMAR_POOL, ENTITY_RESOLVER, XPOINTER_SCHEMA };
  106. /** Property defaults. */
  107. private static final Object[] PROPERTY_DEFAULTS = { null, null, null,null };
  108. // Data
  109. protected XMLDocumentHandler fDocumentHandler;
  110. protected XMLDocumentSource fDocumentSource;
  111. protected XIncludeHandler fParentXIncludeHandler;
  112. protected XMLLocator fDocLocation;
  113. protected XIncludeNamespaceSupport fNamespaceContext;
  114. protected XMLErrorReporter fErrorReporter;
  115. protected XMLGrammarPool fGrammarPool;
  116. protected XMLGrammarDescription fGrammarDesc;
  117. protected DTDGrammar fDTDGrammar;
  118. protected XMLEntityResolver fEntityResolver;
  119. protected ParserConfigurationSettings fSettings;
  120. //protected String fPointerSchema;
  121. protected StringBuffer fPointer;
  122. private int elemCount = 0;
  123. // The current element depth.
  124. // This is used to access the appropriate level of the following stacks.
  125. private int fDepth;
  126. // The depth of the first element to actually be part of the result infoset.
  127. // This will normally be 1, but it could be larger when the top-level item
  128. // is an include, and processing goes to the fallback.
  129. private int fRootDepth;
  130. // this value must be at least 1
  131. private static final int INITIAL_SIZE = 8;
  132. // Used to ensure that fallbacks are always children of include elements,
  133. // and that include elements are never children of other include elements.
  134. // An index contains true if the ancestor of the current element which resides
  135. // at that depth was an include element.
  136. private boolean[] fSawInclude = new boolean[INITIAL_SIZE];
  137. // Ensures that only one fallback element can be at a single depth.
  138. // An index contains true if we have seen any fallback elements at that depth,
  139. // and it is only reset to false when the end tag of the parent is encountered.
  140. private boolean[] fSawFallback = new boolean[INITIAL_SIZE];
  141. // The state of the processor at each given depth.
  142. private int[] fState = new int[INITIAL_SIZE];
  143. QName foundElement = null;
  144. boolean skip = false;
  145. // Constructors
  146. public XPointerElementHandler() {
  147. fDepth = 0;
  148. fRootDepth = 0;
  149. fSawFallback[fDepth] = false;
  150. fSawInclude[fDepth] = false;
  151. fSchemaName="element";
  152. }
  153. // START OF IMPLEMENTATION OF XMLComponent methods //////
  154. public void reset(){
  155. elemCount =0;
  156. fPointerToken = null;
  157. fCurrentTokenint=0;
  158. fCurrentTokenString=null;
  159. fCurrentTokenType=0 ;
  160. fElementCount =0;
  161. fCurrentToken =0;
  162. includeElement = false;
  163. foundElement = null;
  164. skip = false;
  165. fSubResourceIdentified=false;
  166. }
  167. public void reset(XMLComponentManager componentManager)
  168. throws XNIException {
  169. fNamespaceContext = null;
  170. elemCount =0;
  171. fDepth = 0;
  172. fRootDepth = 0;
  173. fPointerToken = null;
  174. fCurrentTokenint=0;
  175. fCurrentTokenString=null;
  176. fCurrentTokenType=0 ;
  177. foundElement = null;
  178. includeElement = false;
  179. skip = false;
  180. fSubResourceIdentified=false;
  181. try {
  182. setErrorReporter(
  183. (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER));
  184. }
  185. catch (XMLConfigurationException e) {
  186. fErrorReporter = null;
  187. }
  188. try {
  189. fGrammarPool =
  190. (XMLGrammarPool)componentManager.getProperty(GRAMMAR_POOL);
  191. }
  192. catch (XMLConfigurationException e) {
  193. fGrammarPool = null;
  194. }
  195. try {
  196. fEntityResolver =
  197. (XMLEntityResolver)componentManager.getProperty(
  198. ENTITY_RESOLVER);
  199. }
  200. catch (XMLConfigurationException e) {
  201. fEntityResolver = null;
  202. }
  203. fSettings = new ParserConfigurationSettings();
  204. Enumeration xercesFeatures = Constants.getXercesFeatures();
  205. while (xercesFeatures.hasMoreElements()) {
  206. String featureId = (String)xercesFeatures.nextElement();
  207. fSettings.addRecognizedFeatures(new String[] { featureId });
  208. try {
  209. fSettings.setFeature(
  210. featureId,
  211. componentManager.getFeature(featureId));
  212. }
  213. catch (XMLConfigurationException e) {
  214. // componentManager doesn't support this feature,
  215. // so we won't worry about it
  216. }
  217. }
  218. /* try{
  219. dtdValidator = (XMLDTDValidator)componentManager.getProperty( Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY);
  220. }Catch(Exception ex){
  221. ex.printStackTrace();
  222. }*/
  223. } // reset(XMLComponentManager)
  224. /**
  225. * Returns a list of feature identifiers that are recognized by
  226. * this component. This method may return null if no features
  227. * are recognized by this component.
  228. */
  229. public String[] getRecognizedFeatures() {
  230. return RECOGNIZED_FEATURES;
  231. } // getRecognizedFeatures():String[]
  232. /**
  233. * Sets the state of a feature. This method is called by the component
  234. * manager any time after reset when a feature changes state.
  235. * <p>
  236. * <strong>Note:</strong> Components should silently ignore features
  237. * that do not affect the operation of the component.
  238. *
  239. * @param featureId The feature identifier.
  240. * @param state The state of the feature.
  241. *
  242. * @throws SAXNotRecognizedException The component should not throw
  243. * this exception.
  244. * @throws SAXNotSupportedException The component should not throw
  245. * this exception.
  246. */
  247. public void setFeature(String featureId, boolean state)
  248. throws XMLConfigurationException {
  249. if (fSettings != null) {
  250. fSettings.setFeature(featureId, state);
  251. }
  252. } // setFeature(String,boolean)
  253. /**
  254. * Returns a list of property identifiers that are recognized by
  255. * this component. This method may return null if no properties
  256. * are recognized by this component.
  257. */
  258. public String[] getRecognizedProperties() {
  259. return RECOGNIZED_PROPERTIES;
  260. } // getRecognizedProperties():String[]
  261. /**
  262. * Sets the value of a property. This method is called by the component
  263. * manager any time after reset when a property changes value.
  264. * <p>
  265. * <strong>Note:</strong> Components should silently ignore properties
  266. * that do not affect the operation of the component.
  267. *
  268. * @param propertyId The property identifier.
  269. * @param value The value of the property.
  270. *
  271. * @throws SAXNotRecognizedException The component should not throw
  272. * this exception.
  273. * @throws SAXNotSupportedException The component should not throw
  274. * this exception.
  275. */
  276. public void setProperty(String propertyId, Object value)
  277. throws XMLConfigurationException {
  278. if (propertyId.equals(ERROR_REPORTER)) {
  279. setErrorReporter((XMLErrorReporter)value);
  280. }
  281. if (propertyId.equals(GRAMMAR_POOL)) {
  282. fGrammarPool = (XMLGrammarPool)value;
  283. }
  284. if (propertyId.equals(ENTITY_RESOLVER)) {
  285. fEntityResolver = (XMLEntityResolver)value;
  286. }
  287. } // setProperty(String,Object)
  288. /**
  289. * Returns the default state for a feature, or null if this
  290. * component does not want to report a default value for this
  291. * feature.
  292. *
  293. * @param featureId The feature identifier.
  294. *
  295. * @since Xerces 2.2.0
  296. */
  297. public Boolean getFeatureDefault(String featureId) {
  298. for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
  299. if (RECOGNIZED_FEATURES[i].equals(featureId)) {
  300. return FEATURE_DEFAULTS[i];
  301. }
  302. }
  303. return null;
  304. } // getFeatureDefault(String):Boolean
  305. /**
  306. * Returns the default state for a property, or null if this
  307. * component does not want to report a default value for this
  308. * property.
  309. *
  310. * @param propertyId The property identifier.
  311. *
  312. * @since Xerces 2.2.0
  313. */
  314. public Object getPropertyDefault(String propertyId) {
  315. for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
  316. if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
  317. return PROPERTY_DEFAULTS[i];
  318. }
  319. }
  320. return null;
  321. } // getPropertyDefault(String):Object
  322. private void setErrorReporter(XMLErrorReporter reporter) {
  323. fErrorReporter = reporter;
  324. if (fErrorReporter != null) {
  325. fErrorReporter.putMessageFormatter(
  326. XIncludeMessageFormatter.XINCLUDE_DOMAIN,
  327. new XIncludeMessageFormatter());
  328. }
  329. }
  330. ///////// END OF IMPLEMENTATION OF XMLComponents methods. //////////
  331. //////// START OF IMPLEMENTATION OF XMLDOCUMENTSOURCE INTERFACE /////////
  332. public void setDocumentHandler(XMLDocumentHandler handler) {
  333. fDocumentHandler = handler;
  334. }
  335. public XMLDocumentHandler getDocumentHandler() {
  336. return fDocumentHandler;
  337. }
  338. /////// END OF IMPLENTATION OF XMLDOCUMENTSOURCE INTERFACE ///////////
  339. /////////////// Implementation of XPointerSchema Methods //////////////////////
  340. String fSchemaName;
  341. String fSchemaPointer;
  342. boolean fSubResourceIdentified;
  343. /**
  344. * set the Schema Name eg element , xpointer
  345. */
  346. public void setXPointerSchemaName(String schemaName){
  347. fSchemaName = schemaName;
  348. }
  349. /**
  350. * Return Schema Name eg element , xpointer
  351. *
  352. */
  353. public String getXpointerSchemaName(){
  354. return fSchemaName;
  355. }
  356. /**
  357. * Parent Contenhandler for the this contenthandler.
  358. * // not sure about the parameter type. It can be Contenthandler instead of Object type.
  359. */
  360. public void setParent(Object parent){
  361. fParentXIncludeHandler = (XIncludeHandler)parent;
  362. }
  363. /**
  364. * return the Parent Contenthandler
  365. */
  366. public Object getParent(){
  367. return fParentXIncludeHandler;
  368. }
  369. /**
  370. * Content of the XPointer Schema. Xpath to be resolved.
  371. */
  372. public void setXPointerSchemaPointer(String content){
  373. fSchemaPointer = content;
  374. }
  375. /**
  376. * Return the XPointer Schema.
  377. */
  378. public String getXPointerSchemaPointer(){
  379. return fSchemaPointer;
  380. }
  381. public boolean isSubResourceIndentified(){
  382. return fSubResourceIdentified;
  383. }
  384. ///////////End Implementation of XPointerSchema Methods //////////////////////
  385. //////////// Tokens Playground ///////////////////
  386. Stack fPointerToken = new Stack();
  387. int fCurrentTokenint=0;
  388. String fCurrentTokenString=null;
  389. int fCurrentTokenType=0 ;// 0 Notype; 1 for integer; 2 for string.
  390. public void getTokens(){
  391. fSchemaPointer = fSchemaPointer.substring(fSchemaPointer.indexOf("(")+1, fSchemaPointer.length());
  392. StringTokenizer st = new StringTokenizer(fSchemaPointer, "/");
  393. String tempToken;
  394. Integer integerToken =null;
  395. Stack tempPointerToken = new Stack();
  396. if(fPointerToken == null){
  397. fPointerToken = new Stack();
  398. }
  399. while(st.hasMoreTokens()){
  400. tempToken=st.nextToken();
  401. try {
  402. integerToken = Integer.valueOf(tempToken);
  403. tempPointerToken.push(integerToken);
  404. }catch(NumberFormatException e){
  405. tempPointerToken.push(tempToken);
  406. }
  407. }
  408. while(!tempPointerToken.empty()){
  409. fPointerToken.push(tempPointerToken.pop());
  410. }
  411. }//getTokens
  412. public boolean hasMoreToken(){
  413. if(fPointerToken.isEmpty())
  414. return false;
  415. else
  416. return true;
  417. }
  418. public boolean getNextToken(){
  419. Object currentToken;
  420. if (!fPointerToken.isEmpty()){
  421. currentToken = fPointerToken.pop();
  422. if(currentToken instanceof Integer){
  423. fCurrentTokenint = ((Integer)currentToken).intValue();
  424. fCurrentTokenType = 1;
  425. }
  426. else{
  427. fCurrentTokenString = ((String)currentToken).toString();
  428. fCurrentTokenType = 2;
  429. }
  430. return true;
  431. }
  432. else {
  433. return false;
  434. }
  435. }
  436. private boolean isIdAttribute(XMLAttributes attributes,Augmentations augs, int index) {
  437. Object o = augs.getItem(Constants.ID_ATTRIBUTE);
  438. if( o instanceof Boolean )
  439. return ((Boolean)o).booleanValue();
  440. return "ID".equals(attributes.getType(index));
  441. }
  442. public boolean checkStringToken(QName element, XMLAttributes attributes){
  443. QName cacheQName = null;
  444. String id =null;
  445. String rawname =null;
  446. QName attrName = new QName();
  447. String attrType = null;
  448. String attrValue = null;
  449. int attrCount = attributes.getLength();
  450. for (int i = 0; i < attrCount; i++) {
  451. Augmentations aaugs = attributes.getAugmentations(i);
  452. attributes.getName(i,attrName);
  453. attrType = attributes.getType(i);
  454. attrValue = attributes.getValue(i);
  455. if(attrType != null && attrValue!= null && isIdAttribute(attributes,aaugs,i) && attrValue.equals(fCurrentTokenString)){
  456. if(hasMoreToken()){
  457. fCurrentTokenType = 0;
  458. fCurrentTokenString = null;
  459. return true;
  460. }
  461. else{
  462. foundElement = element;
  463. includeElement = true;
  464. fCurrentTokenType = 0;
  465. fCurrentTokenString = null;
  466. fSubResourceIdentified = true;
  467. return true;
  468. }
  469. }
  470. }
  471. return false;
  472. }
  473. public boolean checkIntegerToken(QName element){
  474. if(!skip){
  475. fElementCount++;
  476. if(fCurrentTokenint == fElementCount){
  477. if(hasMoreToken()){
  478. fElementCount=0;
  479. fCurrentTokenType = 0;
  480. return true;
  481. }
  482. else{
  483. foundElement = element;
  484. includeElement = true;
  485. fCurrentTokenType = 0;
  486. fElementCount=0;
  487. fSubResourceIdentified =true;
  488. return true;
  489. }
  490. }else{
  491. addQName(element);
  492. skip = true;
  493. return false;
  494. }
  495. }
  496. return false;
  497. }
  498. public void addQName(QName element){
  499. QName cacheQName = new QName(element);
  500. ftempCurrentElement.push(cacheQName);
  501. }
  502. /////////// END TOKEN PLAYGROUND ///////////////
  503. ///// START OF IMPLEMTATION OF XMLDocumentHandler methods //////////
  504. public void startDocument(XMLLocator locator, String encoding,
  505. NamespaceContext namespaceContext, Augmentations augs)
  506. throws XNIException {
  507. getTokens();
  508. }
  509. public void doctypeDecl(String rootElement, String publicId, String systemId,
  510. Augmentations augs)throws XNIException {
  511. }
  512. public void xmlDecl(String version, String encoding, String standalone,
  513. Augmentations augs) throws XNIException {
  514. }
  515. public void comment(XMLString text, Augmentations augs)
  516. throws XNIException {
  517. if (fDocumentHandler != null && includeElement) {
  518. fDocumentHandler.comment(text, augs);
  519. }
  520. }
  521. public void processingInstruction(String target, XMLString data,
  522. Augmentations augs) throws XNIException {
  523. if (fDocumentHandler != null && includeElement) {
  524. fDocumentHandler.processingInstruction(target, data, augs);
  525. }
  526. }
  527. Stack ftempCurrentElement = new Stack();
  528. int fElementCount =0;
  529. int fCurrentToken ;
  530. boolean includeElement;
  531. public void startElement(QName element, XMLAttributes attributes,
  532. Augmentations augs)throws XNIException {
  533. boolean requiredToken=false;
  534. if(fCurrentTokenType == 0)
  535. getNextToken();
  536. if(fCurrentTokenType ==1)
  537. requiredToken = checkIntegerToken(element);
  538. else if (fCurrentTokenType ==2)
  539. requiredToken = checkStringToken(element, attributes);
  540. if(requiredToken && hasMoreToken())
  541. getNextToken();
  542. if(fDocumentHandler != null && includeElement){
  543. elemCount++;
  544. fDocumentHandler.startElement(element, attributes, augs);
  545. }
  546. }
  547. public void endElement(QName element, Augmentations augs)
  548. throws XNIException {
  549. if(includeElement && foundElement != null ){
  550. if(elemCount >0 )elemCount --;
  551. fDocumentHandler.endElement(element, augs);
  552. if(elemCount == 0)includeElement = false;
  553. }else if(!ftempCurrentElement.empty()){
  554. QName name = (QName)ftempCurrentElement.peek();
  555. if(name.equals(element)){
  556. ftempCurrentElement.pop();
  557. skip = false;
  558. }
  559. }
  560. }
  561. public void emptyElement(QName element, XMLAttributes attributes,
  562. Augmentations augs)throws XNIException {
  563. if(fDocumentHandler != null && includeElement){
  564. fDocumentHandler.emptyElement(element, attributes, augs);
  565. }
  566. }
  567. public void startGeneralEntity(String name, XMLResourceIdentifier resId,
  568. String encoding,
  569. Augmentations augs)
  570. throws XNIException {
  571. if (fDocumentHandler != null && includeElement) {
  572. fDocumentHandler.startGeneralEntity(name, resId, encoding, augs);
  573. }
  574. }
  575. public void textDecl(String version, String encoding, Augmentations augs)
  576. throws XNIException {
  577. if (fDocumentHandler != null && includeElement) {
  578. fDocumentHandler.textDecl(version, encoding, augs);
  579. }
  580. }
  581. public void endGeneralEntity(String name, Augmentations augs)
  582. throws XNIException {
  583. if (fDocumentHandler != null) {
  584. fDocumentHandler.endGeneralEntity(name, augs);
  585. }
  586. }
  587. public void characters(XMLString text, Augmentations augs)
  588. throws XNIException {
  589. if (fDocumentHandler != null && includeElement) {
  590. fDocumentHandler.characters(text, augs);
  591. }
  592. }
  593. public void ignorableWhitespace(XMLString text, Augmentations augs)
  594. throws XNIException {
  595. if (fDocumentHandler != null && includeElement) {
  596. fDocumentHandler.ignorableWhitespace(text, augs);
  597. }
  598. }
  599. public void startCDATA(Augmentations augs) throws XNIException {
  600. if (fDocumentHandler != null && includeElement) {
  601. fDocumentHandler.startCDATA(augs);
  602. }
  603. }
  604. public void endCDATA(Augmentations augs) throws XNIException {
  605. if (fDocumentHandler != null && includeElement) {
  606. fDocumentHandler.endCDATA(augs);
  607. }
  608. }
  609. public void endDocument(Augmentations augs) throws XNIException {
  610. }
  611. public void setDocumentSource(XMLDocumentSource source) {
  612. fDocumentSource = source;
  613. }
  614. public XMLDocumentSource getDocumentSource() {
  615. return fDocumentSource;
  616. }
  617. protected void reportFatalError(String key) {
  618. this.reportFatalError(key, null);
  619. }
  620. protected void reportFatalError(String key, Object[] args) {
  621. if (fErrorReporter != null) {
  622. fErrorReporter.reportError(
  623. fDocLocation,
  624. XIncludeMessageFormatter.XINCLUDE_DOMAIN,
  625. key,
  626. args,
  627. XMLErrorReporter.SEVERITY_FATAL_ERROR);
  628. }
  629. // we won't worry about when error reporter is null, since there should always be
  630. // at least the default error reporter
  631. }
  632. // used to know whether to pass declarations to the document handler
  633. protected boolean isRootDocument() {
  634. return this.fParentXIncludeHandler == null;
  635. }
  636. } // class XPointerElementhandler