private String getBaseURIOfIncludedStylesheet ( StylesheetHandler handler , Source s ) throws TransformerException { String baseURI ; String idFromUriResolverSource ; if ( s != null && ( idFromUriResolverSource = s . getSystemId ( ) ) != null ) { // We have a Source obtained from a users's URIResolver, // and the system ID is set on it, so return that as the base URI baseURI = idFromUriResolverSource ; } else { // The user did not provide a URIResolver, or it did not // return a Source for the included stylesheet module, or // the Source has no system ID set, so we fall back to using // the system ID Resolver to take the href and base // to generate the baseURI of the included stylesheet. baseURI = SystemIDResolver . getAbsoluteURI ( getHref ( ) , handler . getBaseIdentifier ( ) ) ; } return baseURI ; }
Get the base URI of the included or imported stylesheet if the user provided a URIResolver then get the Source object for the stylsheet from it and get the systemId from that Source object otherwise try to recover by using the SysteIDResolver to figure out the base URI .