mrglavas    2005/02/18 13:30:23

  Modified:    java/src/org/apache/xerces/xinclude XIncludeHandler.java
  Log:
  Added support for two new features which control whether base URI fixup or 
language fixup is performed.
  
  Enable base URI fixup: 
http://apache.org/xml/features/xinclude/fixup-base-uris (default: true)
  Enable language fixup: http://apache.org/xml/features/xinclude/fixup-language 
(default: true)
  
  Revision  Changes    Path
  1.44      +49 -8     
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java
  
  Index: XIncludeHandler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- XIncludeHandler.java      17 Feb 2005 05:52:02 -0000      1.43
  +++ XIncludeHandler.java      18 Feb 2005 21:30:23 -0000      1.44
  @@ -190,6 +190,14 @@
           Constants.SAX_FEATURE_PREFIX
               + Constants.ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE;
       
  +    /** Feature identifier: fixup base URIs. */
  +    protected static final String XINCLUDE_FIXUP_BASE_URIS =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.XINCLUDE_FIXUP_BASE_URIS_FEATURE;
  +    
  +    /** Feature identifier: fixup language. */
  +    protected static final String XINCLUDE_FIXUP_LANGUAGE =
  +        Constants.XERCES_FEATURE_PREFIX + 
Constants.XINCLUDE_FIXUP_LANGUAGE_FEATURE;
  +    
       /** Property identifier: symbol table. */
       protected static final String SYMBOL_TABLE = 
           Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
  @@ -215,10 +223,10 @@
   
       /** Recognized features. */
       private static final String[] RECOGNIZED_FEATURES =
  -        { ALLOW_UE_AND_NOTATION_EVENTS };
  +        { ALLOW_UE_AND_NOTATION_EVENTS, XINCLUDE_FIXUP_BASE_URIS, 
XINCLUDE_FIXUP_LANGUAGE };
   
       /** Feature defaults. */
  -    private static final Boolean[] FEATURE_DEFAULTS = { Boolean.TRUE };
  +    private static final Boolean[] FEATURE_DEFAULTS = { Boolean.TRUE, 
Boolean.TRUE, Boolean.TRUE };
   
       /** Recognized properties. */
       private static final String[] RECOGNIZED_PROPERTIES =
  @@ -305,6 +313,10 @@
       // buffering the necessary DTD events
       private ArrayList fNotations;
       private ArrayList fUnparsedEntities;
  +    
  +    // flags which control whether base URI or language fixup is performed.
  +    private boolean fFixupBaseURIs = true;
  +    private boolean fFixupLanguage = true;
   
       // for SAX compatibility.
       // Has the value of the ALLOW_UE_AND_NOTATION_EVENTS feature
  @@ -404,6 +416,32 @@
           catch (XMLConfigurationException e) {
           }
           
  +        try {
  +            fFixupBaseURIs =
  +                componentManager.getFeature(XINCLUDE_FIXUP_BASE_URIS);
  +            if (fChildConfig != null) {
  +                fChildConfig.setFeature(
  +                    XINCLUDE_FIXUP_BASE_URIS,
  +                    fFixupBaseURIs);
  +            }
  +        }
  +        catch (XMLConfigurationException e) {
  +            fFixupBaseURIs = true;
  +        }
  +        
  +        try {
  +            fFixupLanguage =
  +                componentManager.getFeature(XINCLUDE_FIXUP_LANGUAGE);
  +            if (fChildConfig != null) {
  +                fChildConfig.setFeature(
  +                    XINCLUDE_FIXUP_LANGUAGE,
  +                    fFixupLanguage);
  +            }
  +        }
  +        catch (XMLConfigurationException e) {
  +            fFixupLanguage = true;
  +        }
  +        
           // Get symbol table.
           try {
               SymbolTable value =
  @@ -797,7 +835,9 @@
           // we process the xml:base and xml:lang attributes regardless
           // of what type of element it is.
           processXMLBaseAttributes(attributes);
  -        processXMLLangAttributes(attributes);
  +        if (fFixupLanguage) {
  +            processXMLLangAttributes(attributes);
  +        }
   
           if (isIncludeElement(element)) {
               boolean success = this.handleIncludeElement(attributes);
  @@ -856,7 +896,9 @@
           // we process the xml:base and xml:lang attributes regardless
           // of what type of element it is.
           processXMLBaseAttributes(attributes);
  -        processXMLLangAttributes(attributes);
  +        if (fFixupLanguage) {
  +            processXMLLangAttributes(attributes);
  +        }
   
           if (isIncludeElement(element)) {
               boolean success = this.handleIncludeElement(attributes);
  @@ -1752,14 +1794,13 @@
               // Modify attributes to fix the base URI (spec 4.5.5).
               // We only do it to top level included elements, which have a 
different
               // base URI than their include parent.
  -            if (!sameBaseURIAsIncludeParent()) {
  +            if (fFixupBaseURIs && !sameBaseURIAsIncludeParent()) {
                   if (attributes == null) {
                       attributes = new XMLAttributesImpl();
                   }
   
                   // This causes errors with schema validation, if the schema 
doesn't
                   // specify that these elements can have an xml:base attribute
  -                // TODO: add a user option to turn this off?
                   String uri = null;
                   try {
                       uri = this.getRelativeBaseURI();
  @@ -1780,7 +1821,7 @@
               // Modify attributes to perform language-fixup (spec 4.5.6).
               // We only do it to top level included elements, which have a 
different
               // [language] than their include parent.
  -            if (!sameLanguageAsIncludeParent()) {
  +            if (fFixupLanguage && !sameLanguageAsIncludeParent()) {
                   if (attributes == null) {
                       attributes = new XMLAttributesImpl();
                   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to