src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java

Print this page


   1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2003-2005 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at

  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */

  20 package com.sun.org.apache.xerces.internal.xinclude;
  21 
  22 import java.io.CharConversionException;
  23 import java.io.IOException;
  24 import java.util.ArrayList;
  25 import java.util.Enumeration;
  26 import java.util.Locale;
  27 import java.util.Stack;
  28 import java.util.StringTokenizer;
  29 import javax.xml.XMLConstants;
  30 
  31 import com.sun.org.apache.xerces.internal.impl.Constants;
  32 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  33 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
  34 import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
  35 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
  36 import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
  37 import com.sun.org.apache.xerces.internal.util.HTTPInputSource;
  38 import com.sun.org.apache.xerces.internal.util.IntStack;
  39 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;


  53 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  54 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  55 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
  56 import com.sun.org.apache.xerces.internal.xni.XMLString;
  57 import com.sun.org.apache.xerces.internal.xni.XNIException;
  58 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
  59 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
  60 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  61 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDFilter;
  62 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
  63 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentFilter;
  64 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  65 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  66 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  67 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
  68 import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
  69 import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
  70 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
  71 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
  72 import java.util.Objects;








  73 
  74 /**
  75  * <p>
  76  * This is a pipeline component which performs XInclude handling, according to the
  77  * W3C specification for XML Inclusions.
  78  * </p>
  79  * <p>
  80  * This component analyzes each event in the pipeline, looking for &lt;include&gt;
  81  * elements. An &lt;include&gt; element is one which has a namespace of
  82  * <code>http://www.w3.org/2001/XInclude</code> and a localname of <code>include</code>.
  83  * When it finds an &lt;include&gt; element, it attempts to include the file specified
  84  * in the <code>href</code> attribute of the element.  If inclusion succeeds, all
  85  * children of the &lt;include&gt; element are ignored (with the exception of
  86  * checking for invalid children as outlined in the specification).  If the inclusion
  87  * fails, the &lt;fallback&gt; child of the &lt;include&gt; element is processed.
  88  * </p>
  89  * <p>
  90  * See the <a href="http://www.w3.org/TR/xinclude/">XInclude specification</a> for
  91  * more information on how XInclude is to be used.
  92  * </p>


 230 
 231     protected static final String PARSER_SETTINGS =
 232         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
 233 
 234     /** property identifier: XML security property manager. */
 235     protected static final String XML_SECURITY_PROPERTY_MANAGER =
 236             Constants.XML_SECURITY_PROPERTY_MANAGER;
 237 
 238     /** Recognized features. */
 239     private static final String[] RECOGNIZED_FEATURES =
 240         { ALLOW_UE_AND_NOTATION_EVENTS, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE };
 241 
 242     /** Feature defaults. */
 243     private static final Boolean[] FEATURE_DEFAULTS = { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE };
 244 
 245     /** Recognized properties. */
 246     private static final String[] RECOGNIZED_PROPERTIES =
 247         { ERROR_REPORTER, ENTITY_RESOLVER, SECURITY_MANAGER, BUFFER_SIZE };
 248 
 249     /** Property defaults. */
 250     private static final Object[] PROPERTY_DEFAULTS = { null, null, null, new Integer(XMLEntityManager.DEFAULT_BUFFER_SIZE) };
 251 
 252     // instance variables
 253 
 254     // for XMLDocumentFilter
 255     protected XMLDocumentHandler fDocumentHandler;
 256     protected XMLDocumentSource fDocumentSource;
 257 
 258     // for XMLDTDFilter
 259     protected XMLDTDHandler fDTDHandler;
 260     protected XMLDTDSource fDTDSource;
 261 
 262     // for XIncludeHandler
 263     protected XIncludeHandler fParentXIncludeHandler;
 264 
 265     // for buffer size in XIncludeTextReader
 266     protected int fBufferSize = XMLEntityManager.DEFAULT_BUFFER_SIZE;
 267 
 268     // It "feels wrong" to store this value here.  However,
 269     // calculating it can be time consuming, so we cache it.
 270     // It's never going to change in the lifetime of this XIncludeHandler


 318     private int fResultDepth;
 319 
 320     // this value must be at least 1
 321     private static final int INITIAL_SIZE = 8;
 322 
 323     // Used to ensure that fallbacks are always children of include elements,
 324     // and that include elements are never children of other include elements.
 325     // An index contains true if the ancestor of the current element which resides
 326     // at that depth was an include element.
 327     private boolean[] fSawInclude = new boolean[INITIAL_SIZE];
 328 
 329     // Ensures that only one fallback element can be at a single depth.
 330     // An index contains true if we have seen any fallback elements at that depth,
 331     // and it is only reset to false when the end tag of the parent is encountered.
 332     private boolean[] fSawFallback = new boolean[INITIAL_SIZE];
 333 
 334     // The state of the processor at each given depth.
 335     private int[] fState = new int[INITIAL_SIZE];
 336 
 337     // buffering the necessary DTD events
 338     private ArrayList fNotations;
 339     private ArrayList fUnparsedEntities;
 340 
 341     // flags which control whether base URI or language fixup is performed.
 342     private boolean fFixupBaseURIs = true;
 343     private boolean fFixupLanguage = true;
 344 
 345     // for SAX compatibility.
 346     // Has the value of the ALLOW_UE_AND_NOTATION_EVENTS feature
 347     private boolean fSendUEAndNotationEvents;
 348 
 349     // track the version of the document being parsed
 350     private boolean fIsXML11;
 351 
 352     // track whether a DTD is being parsed
 353     private boolean fInDTD;
 354 
 355     // track whether the root element of the result infoset has been processed
 356     private boolean fSeenRootElement;
 357 
 358     // track whether the child config needs its features refreshed
 359     private boolean fNeedCopyFeatures = true;
 360 











 361     // Constructors
 362 
 363     public XIncludeHandler() {
 364         fDepth = 0;
 365 
 366         fSawFallback[fDepth] = false;
 367         fSawInclude[fDepth] = false;
 368         fState[fDepth] = STATE_NORMAL_PROCESSING;
 369         fNotations = new ArrayList();
 370         fUnparsedEntities = new ArrayList();
 371 
 372         fBaseURIScope = new IntStack();
 373         fBaseURI = new Stack();
 374         fLiteralSystemID = new Stack();
 375         fExpandedSystemID = new Stack();
 376         fCurrentBaseURI = new XMLResourceIdentifierImpl();
 377 
 378         fLanguageScope = new IntStack();
 379         fLanguageStack = new Stack();
 380         fCurrentLanguage = null;
 381     }
 382 
 383     // XMLComponent methods
 384 
 385     @Override
 386     public void reset(XMLComponentManager componentManager)
 387         throws XNIException {
 388         fNamespaceContext = null;
 389         fDepth = 0;
 390         fResultDepth = isRootDocument() ? 0 : fParentXIncludeHandler.getResultDepth();


 517         // Get security manager.
 518         try {
 519             XMLSecurityManager value =
 520                 (XMLSecurityManager)componentManager.getProperty(
 521                     SECURITY_MANAGER);
 522 
 523             if (value != null) {
 524                 fSecurityManager = value;
 525                 if (fChildConfig != null) {
 526                     fChildConfig.setProperty(SECURITY_MANAGER, value);
 527                 }
 528             }
 529         }
 530         catch (XMLConfigurationException e) {
 531             fSecurityManager = null;
 532         }
 533 
 534         fSecurityPropertyMgr = (XMLSecurityPropertyManager)
 535                 componentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER);
 536 







 537         // Get buffer size.
 538         try {
 539             Integer value =
 540                 (Integer)componentManager.getProperty(
 541                     BUFFER_SIZE);
 542 
 543             if (value != null && value.intValue() > 0) {
 544                 fBufferSize = value.intValue();
 545                 if (fChildConfig != null) {
 546                     fChildConfig.setProperty(BUFFER_SIZE, value);
 547                 }
 548             }
 549             else {
 550                 fBufferSize = ((Integer)getPropertyDefault(BUFFER_SIZE)).intValue();
 551             }
 552         }
 553         catch (XMLConfigurationException e) {
 554                 fBufferSize = ((Integer)getPropertyDefault(BUFFER_SIZE)).intValue();
 555         }
 556 
 557         // Reset XML 1.0 text reader.
 558         if (fXInclude10TextReader != null) {
 559                 fXInclude10TextReader.setBufferSize(fBufferSize);
 560         }
 561         // Reset XML 1.1 text reader.
 562         if (fXInclude11TextReader != null) {
 563             fXInclude11TextReader.setBufferSize(fBufferSize);
 564         }
 565 
 566         fSettings = new ParserConfigurationSettings();
 567         copyFeatures(componentManager, fSettings);
 568 
 569         // We don't want a schema validator on the new pipeline,
 570         // so if it was enabled, we set the feature to false. If
 571         // the validation feature was also enabled we turn on
 572         // dynamic validation, so that DTD validation is performed
 573         // on the included documents only if they have a DOCTYPE.
 574         // This is consistent with the behaviour on the main pipeline.


1581         if (acceptLanguage != null && !isValidInHTTPHeader(acceptLanguage)) {
1582             reportFatalError("AcceptLanguageMalformed", null);
1583             acceptLanguage = null;
1584         }
1585 
1586         XMLInputSource includedSource = null;
1587         if (fEntityResolver != null) {
1588             try {
1589                 XMLResourceIdentifier resourceIdentifier =
1590                     new XMLResourceIdentifierImpl(
1591                         null,
1592                         href,
1593                         fCurrentBaseURI.getExpandedSystemId(),
1594                         XMLEntityManager.expandSystemId(
1595                             href,
1596                             fCurrentBaseURI.getExpandedSystemId(),
1597                             false));
1598 
1599                 includedSource =
1600                     fEntityResolver.resolveEntity(resourceIdentifier);

































1601 
1602                 if (includedSource != null &&
1603                     !(includedSource instanceof HTTPInputSource) &&
1604                     (accept != null || acceptLanguage != null) &&
1605                     includedSource.getCharacterStream() == null &&
1606                     includedSource.getByteStream() == null) {
1607 
1608                     includedSource = createInputSource(includedSource.getPublicId(), includedSource.getSystemId(),
1609                         includedSource.getBaseSystemId(), accept, acceptLanguage);
1610                 }
1611             }
1612             catch (IOException e) {
1613                 reportResourceError(
1614                     "XMLResourceError",
1615                     new Object[] { href, e.getMessage()});
1616                 return false;
1617             }
1618         }
1619 
1620         if (includedSource == null) {


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.

   3  */
   4 /*
   5  * Licensed to the Apache Software Foundation (ASF) under one or more
   6  * contributor license agreements.  See the NOTICE file distributed with
   7  * this work for additional information regarding copyright ownership.
   8  * The ASF licenses this file to You under the Apache License, Version 2.0
   9  * (the "License"); you may not use this file except in compliance with
  10  * the License.  You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.xinclude;
  22 
  23 import java.io.CharConversionException;
  24 import java.io.IOException;
  25 import java.util.ArrayList;
  26 import java.util.Enumeration;
  27 import java.util.Locale;
  28 import java.util.Stack;
  29 import java.util.StringTokenizer;
  30 import javax.xml.XMLConstants;
  31 
  32 import com.sun.org.apache.xerces.internal.impl.Constants;
  33 import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
  34 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
  35 import com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException;
  36 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
  37 import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
  38 import com.sun.org.apache.xerces.internal.util.HTTPInputSource;
  39 import com.sun.org.apache.xerces.internal.util.IntStack;
  40 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;


  54 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
  55 import com.sun.org.apache.xerces.internal.xni.XMLLocator;
  56 import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
  57 import com.sun.org.apache.xerces.internal.xni.XMLString;
  58 import com.sun.org.apache.xerces.internal.xni.XNIException;
  59 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
  60 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
  61 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
  62 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDFilter;
  63 import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
  64 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentFilter;
  65 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
  66 import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver;
  67 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource;
  68 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
  69 import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
  70 import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
  71 import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
  72 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager;
  73 import java.util.Objects;
  74 import javax.xml.catalog.CatalogException;
  75 import javax.xml.catalog.CatalogFeatures;
  76 import javax.xml.catalog.CatalogManager;
  77 import javax.xml.catalog.CatalogResolver;
  78 import javax.xml.catalog.CatalogUriResolver;
  79 import javax.xml.transform.Source;
  80 import jdk.xml.internal.JdkXmlUtils;
  81 import org.xml.sax.InputSource;
  82 
  83 /**
  84  * <p>
  85  * This is a pipeline component which performs XInclude handling, according to the
  86  * W3C specification for XML Inclusions.
  87  * </p>
  88  * <p>
  89  * This component analyzes each event in the pipeline, looking for &lt;include&gt;
  90  * elements. An &lt;include&gt; element is one which has a namespace of
  91  * <code>http://www.w3.org/2001/XInclude</code> and a localname of <code>include</code>.
  92  * When it finds an &lt;include&gt; element, it attempts to include the file specified
  93  * in the <code>href</code> attribute of the element.  If inclusion succeeds, all
  94  * children of the &lt;include&gt; element are ignored (with the exception of
  95  * checking for invalid children as outlined in the specification).  If the inclusion
  96  * fails, the &lt;fallback&gt; child of the &lt;include&gt; element is processed.
  97  * </p>
  98  * <p>
  99  * See the <a href="http://www.w3.org/TR/xinclude/">XInclude specification</a> for
 100  * more information on how XInclude is to be used.
 101  * </p>


 239 
 240     protected static final String PARSER_SETTINGS =
 241         Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
 242 
 243     /** property identifier: XML security property manager. */
 244     protected static final String XML_SECURITY_PROPERTY_MANAGER =
 245             Constants.XML_SECURITY_PROPERTY_MANAGER;
 246 
 247     /** Recognized features. */
 248     private static final String[] RECOGNIZED_FEATURES =
 249         { ALLOW_UE_AND_NOTATION_EVENTS, XINCLUDE_FIXUP_BASE_URIS, XINCLUDE_FIXUP_LANGUAGE };
 250 
 251     /** Feature defaults. */
 252     private static final Boolean[] FEATURE_DEFAULTS = { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE };
 253 
 254     /** Recognized properties. */
 255     private static final String[] RECOGNIZED_PROPERTIES =
 256         { ERROR_REPORTER, ENTITY_RESOLVER, SECURITY_MANAGER, BUFFER_SIZE };
 257 
 258     /** Property defaults. */
 259     private static final Object[] PROPERTY_DEFAULTS = { null, null, null, XMLEntityManager.DEFAULT_BUFFER_SIZE};
 260 
 261     // instance variables
 262 
 263     // for XMLDocumentFilter
 264     protected XMLDocumentHandler fDocumentHandler;
 265     protected XMLDocumentSource fDocumentSource;
 266 
 267     // for XMLDTDFilter
 268     protected XMLDTDHandler fDTDHandler;
 269     protected XMLDTDSource fDTDSource;
 270 
 271     // for XIncludeHandler
 272     protected XIncludeHandler fParentXIncludeHandler;
 273 
 274     // for buffer size in XIncludeTextReader
 275     protected int fBufferSize = XMLEntityManager.DEFAULT_BUFFER_SIZE;
 276 
 277     // It "feels wrong" to store this value here.  However,
 278     // calculating it can be time consuming, so we cache it.
 279     // It's never going to change in the lifetime of this XIncludeHandler


 327     private int fResultDepth;
 328 
 329     // this value must be at least 1
 330     private static final int INITIAL_SIZE = 8;
 331 
 332     // Used to ensure that fallbacks are always children of include elements,
 333     // and that include elements are never children of other include elements.
 334     // An index contains true if the ancestor of the current element which resides
 335     // at that depth was an include element.
 336     private boolean[] fSawInclude = new boolean[INITIAL_SIZE];
 337 
 338     // Ensures that only one fallback element can be at a single depth.
 339     // An index contains true if we have seen any fallback elements at that depth,
 340     // and it is only reset to false when the end tag of the parent is encountered.
 341     private boolean[] fSawFallback = new boolean[INITIAL_SIZE];
 342 
 343     // The state of the processor at each given depth.
 344     private int[] fState = new int[INITIAL_SIZE];
 345 
 346     // buffering the necessary DTD events
 347     private final ArrayList<Notation> fNotations;
 348     private final ArrayList<UnparsedEntity> fUnparsedEntities;
 349 
 350     // flags which control whether base URI or language fixup is performed.
 351     private boolean fFixupBaseURIs = true;
 352     private boolean fFixupLanguage = true;
 353 
 354     // for SAX compatibility.
 355     // Has the value of the ALLOW_UE_AND_NOTATION_EVENTS feature
 356     private boolean fSendUEAndNotationEvents;
 357 
 358     // track the version of the document being parsed
 359     private boolean fIsXML11;
 360 
 361     // track whether a DTD is being parsed
 362     private boolean fInDTD;
 363 
 364     // track whether the root element of the result infoset has been processed
 365     private boolean fSeenRootElement;
 366 
 367     // track whether the child config needs its features refreshed
 368     private boolean fNeedCopyFeatures = true;
 369 
 370     /** indicate whether Catalog should be used for resolving external resources */
 371     private boolean fUseCatalog = true;
 372     CatalogFeatures fCatalogFeatures;
 373     CatalogResolver fCatalogResolver;
 374     CatalogUriResolver fCatalogUriResolver;
 375 
 376     private String fCatalogFile;
 377     private String fDefer;
 378     private String fPrefer;
 379     private String fResolve;
 380 
 381     // Constructors
 382 
 383     public XIncludeHandler() {
 384         fDepth = 0;
 385 
 386         fSawFallback[fDepth] = false;
 387         fSawInclude[fDepth] = false;
 388         fState[fDepth] = STATE_NORMAL_PROCESSING;
 389         fNotations = new ArrayList<>();
 390         fUnparsedEntities = new ArrayList<>();
 391 
 392         fBaseURIScope = new IntStack();
 393         fBaseURI = new Stack();
 394         fLiteralSystemID = new Stack();
 395         fExpandedSystemID = new Stack();
 396         fCurrentBaseURI = new XMLResourceIdentifierImpl();
 397 
 398         fLanguageScope = new IntStack();
 399         fLanguageStack = new Stack();
 400         fCurrentLanguage = null;
 401     }
 402 
 403     // XMLComponent methods
 404 
 405     @Override
 406     public void reset(XMLComponentManager componentManager)
 407         throws XNIException {
 408         fNamespaceContext = null;
 409         fDepth = 0;
 410         fResultDepth = isRootDocument() ? 0 : fParentXIncludeHandler.getResultDepth();


 537         // Get security manager.
 538         try {
 539             XMLSecurityManager value =
 540                 (XMLSecurityManager)componentManager.getProperty(
 541                     SECURITY_MANAGER);
 542 
 543             if (value != null) {
 544                 fSecurityManager = value;
 545                 if (fChildConfig != null) {
 546                     fChildConfig.setProperty(SECURITY_MANAGER, value);
 547                 }
 548             }
 549         }
 550         catch (XMLConfigurationException e) {
 551             fSecurityManager = null;
 552         }
 553 
 554         fSecurityPropertyMgr = (XMLSecurityPropertyManager)
 555                 componentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER);
 556 
 557         //Use Catalog
 558         fUseCatalog = componentManager.getFeature(XMLConstants.USE_CATALOG);
 559         fCatalogFile = (String)componentManager.getProperty(CatalogFeatures.Feature.FILES.getPropertyName());
 560         fDefer = (String)componentManager.getProperty(CatalogFeatures.Feature.DEFER.getPropertyName());
 561         fPrefer = (String)componentManager.getProperty(CatalogFeatures.Feature.PREFER.getPropertyName());
 562         fResolve = (String)componentManager.getProperty(CatalogFeatures.Feature.RESOLVE.getPropertyName());
 563 
 564         // Get buffer size.
 565         try {
 566             Integer value =
 567                 (Integer)componentManager.getProperty(
 568                     BUFFER_SIZE);
 569 
 570             if (value != null && value > 0) {
 571                 fBufferSize = value;
 572                 if (fChildConfig != null) {
 573                     fChildConfig.setProperty(BUFFER_SIZE, value);
 574                 }
 575             }
 576             else {
 577                 fBufferSize = ((Integer)getPropertyDefault(BUFFER_SIZE));
 578             }
 579         }
 580         catch (XMLConfigurationException e) {
 581             fBufferSize = ((Integer)getPropertyDefault(BUFFER_SIZE));
 582         }
 583 
 584         // Reset XML 1.0 text reader.
 585         if (fXInclude10TextReader != null) {
 586                 fXInclude10TextReader.setBufferSize(fBufferSize);
 587         }
 588         // Reset XML 1.1 text reader.
 589         if (fXInclude11TextReader != null) {
 590             fXInclude11TextReader.setBufferSize(fBufferSize);
 591         }
 592 
 593         fSettings = new ParserConfigurationSettings();
 594         copyFeatures(componentManager, fSettings);
 595 
 596         // We don't want a schema validator on the new pipeline,
 597         // so if it was enabled, we set the feature to false. If
 598         // the validation feature was also enabled we turn on
 599         // dynamic validation, so that DTD validation is performed
 600         // on the included documents only if they have a DOCTYPE.
 601         // This is consistent with the behaviour on the main pipeline.


1608         if (acceptLanguage != null && !isValidInHTTPHeader(acceptLanguage)) {
1609             reportFatalError("AcceptLanguageMalformed", null);
1610             acceptLanguage = null;
1611         }
1612 
1613         XMLInputSource includedSource = null;
1614         if (fEntityResolver != null) {
1615             try {
1616                 XMLResourceIdentifier resourceIdentifier =
1617                     new XMLResourceIdentifierImpl(
1618                         null,
1619                         href,
1620                         fCurrentBaseURI.getExpandedSystemId(),
1621                         XMLEntityManager.expandSystemId(
1622                             href,
1623                             fCurrentBaseURI.getExpandedSystemId(),
1624                             false));
1625 
1626                 includedSource =
1627                     fEntityResolver.resolveEntity(resourceIdentifier);
1628 
1629                 if (includedSource == null) {
1630                     if (fCatalogFeatures == null) {
1631                         fCatalogFeatures = JdkXmlUtils.getCatalogFeatures(fDefer, fCatalogFile, fPrefer, fResolve);
1632                     }
1633                     fCatalogFile = fCatalogFeatures.get(CatalogFeatures.Feature.FILES);
1634                     if (fUseCatalog && fCatalogFile != null) {
1635                         /*
1636                            Although URI entry is preferred for resolving XInclude, system entry
1637                            is allowed as well.
1638                         */
1639                         Source source = null;
1640                         try {
1641                             if (fCatalogUriResolver == null) {
1642                                 fCatalogUriResolver = CatalogManager.catalogUriResolver(fCatalogFeatures);
1643                             }
1644                             source = fCatalogUriResolver.resolve(href, fCurrentBaseURI.getExpandedSystemId());
1645                         } catch (CatalogException e) {}
1646 
1647                         if (source != null && !source.isEmpty()) {
1648                             includedSource = new XMLInputSource(null, source.getSystemId(),
1649                                     fCurrentBaseURI.getExpandedSystemId(), true);
1650                         } else {
1651                             if (fCatalogResolver == null) {
1652                                 fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures);
1653                             }
1654                             InputSource is = fCatalogResolver.resolveEntity(href, href);
1655                             if (is != null && !is.isEmpty()) {
1656                                 includedSource = new XMLInputSource(is, true);
1657                             }
1658                         }
1659                     }
1660                 }
1661 
1662                 if (includedSource != null &&
1663                     !(includedSource instanceof HTTPInputSource) &&
1664                     (accept != null || acceptLanguage != null) &&
1665                     includedSource.getCharacterStream() == null &&
1666                     includedSource.getByteStream() == null) {
1667 
1668                     includedSource = createInputSource(includedSource.getPublicId(), includedSource.getSystemId(),
1669                         includedSource.getBaseSystemId(), accept, acceptLanguage);
1670                 }
1671             }
1672             catch (IOException e) {
1673                 reportResourceError(
1674                     "XMLResourceError",
1675                     new Object[] { href, e.getMessage()});
1676                 return false;
1677             }
1678         }
1679 
1680         if (includedSource == null) {