mrglavas    2005/05/05 10:59:55

  Modified:    java/src/org/apache/xerces/xinclude XIncludeHandler.java
  Log:
  When href is absent and parse="text" the source infoset should be included as 
text.
  We had been reporting a fatal error for missing an xpointer which isn't even 
allowed
  when parse="text".
  
  Revision  Changes    Path
  1.47      +27 -24    
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.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- XIncludeHandler.java      13 Apr 2005 18:27:04 -0000      1.46
  +++ XIncludeHandler.java      5 May 2005 17:59:55 -0000       1.47
  @@ -1427,43 +1427,46 @@
           String accept = attributes.getValue(XINCLUDE_ATTR_ACCEPT);
           String acceptLanguage = 
attributes.getValue(XINCLUDE_ATTR_ACCEPT_LANGUAGE);
           
  -        if (href == null && xpointer == null) {
  -            reportFatalError("XpointerMissing");
  -        }
           if (parse == null) {
               parse = XINCLUDE_PARSE_XML;
           }
  -        
  +        if (href == null) {
  +            href = XMLSymbols.EMPTY_STRING;
  +        }
  +        if (href.length() == 0 && XINCLUDE_PARSE_XML.equals(parse)) {
  +            if (xpointer == null) {
  +                reportFatalError("XpointerMissing");
  +            }
  +        }
  +
           URI hrefURI = null;
           
           // Check whether href is correct and perform escaping as per section 
4.1.1 of the XInclude spec.
           // Report fatal error if the href value contains a fragment 
identifier or if the value after
           // escaping is a syntactically invalid URI or IRI.
  -        if (href != null) {
  -            try {
  -                hrefURI = new URI(href, true);
  -                if (hrefURI.getFragment() != null) {
  -                    reportFatalError("HrefFragmentIdentifierIllegal", new 
Object[] {href});
  -                }
  +        try {
  +            hrefURI = new URI(href, true);
  +            if (hrefURI.getFragment() != null) {
  +                reportFatalError("HrefFragmentIdentifierIllegal", new 
Object[] {href});
               }
  -            catch (URI.MalformedURIException exc) {
  -                String newHref = escapeHref(href);
  -                if (href != newHref) {
  -                    href = newHref;
  -                    try {
  -                        hrefURI = new URI(href, true);
  -                        if (hrefURI.getFragment() != null) {
  -                            
reportFatalError("HrefFragmentIdentifierIllegal", new Object[] {href});
  -                        }
  -                    }
  -                    catch (URI.MalformedURIException exc2) {
  -                        reportFatalError("HrefSyntacticallyInvalid", new 
Object[] {href});
  +        }
  +        catch (URI.MalformedURIException exc) {
  +            String newHref = escapeHref(href);
  +            if (href != newHref) {
  +                href = newHref;
  +                try {
  +                    hrefURI = new URI(href, true);
  +                    if (hrefURI.getFragment() != null) {
  +                        reportFatalError("HrefFragmentIdentifierIllegal", 
new Object[] {href});
                       }
                   }
  -                else {
  +                catch (URI.MalformedURIException exc2) {
                       reportFatalError("HrefSyntacticallyInvalid", new 
Object[] {href});
                   }
               }
  +            else {
  +                reportFatalError("HrefSyntacticallyInvalid", new Object[] 
{href});
  +            }
           }
           
           // Verify that if an accept and/or an accept-language attribute exist
  
  
  

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

Reply via email to