org.enhydra.xml.xmlc.misc
Class SSISystemIdResolver

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.misc.SSISystemIdResolver

public class SSISystemIdResolver
extends Object

Resolves SSI systemIds relative to either resource loader contexts (when a resource loader is provided) or the parent systemId.

Note: providing the 'includingFilePath' to the constructor is useful for determining the operative root to use for relative SSI paths. And when moving back directories, it is used to avoid moving past the operative root of 'file:'-based SystemIds. For instance...

systemId
"file:/C:///apache-tomcat/webapps/app/WEB-INF/classes/org/company/app/package/path/to/somefile.html"
ssiPath (irrational value that moves back waaayyy too many directories)
"../../../../../../../../../../../../../../../../../../../../../includes/include.ssi"
includingFilePath
"org/company/app/package/path/to/somefile.html"
Resolved SSI systemId using above includingFilePath...
file:/C:///apache-tomcat/webapps/app/WEB-INF/classes/includes/include.ssi
Resolved SSI systemId NOT using above includingFilePath...
file:/C:///includes/include.ssi

Notice that with 'includingFilePath', the operative root is "file:/C:///..../WEB-INF/classes/" and without 'includingFilePath' the operative root is "file:/C:///". The first case is probably more useful, but notice that in both cases the value is rational. That is, the result remains a valid URL even in the face of the irrational "ssiPath" value moving back waaayyy to many directories. Both "jar:file:/" and "http://" URLs are handled, respectively, in rational ways as well.

Note: paths containing "." or ".." starting in the middle/end of the path (e.g., "/somedir/../../include.ssi") are not resolved to the corresponding directories and, instead, remain as-is in the systemId. Therefore, when defining SSI include paths or the ssiBase path, any "." or ".." should start at the beginning of the path (e.g., "../include.ssi").

Since:
2.3.3
Author:
Jacob Kjome

Constructor Summary
SSISystemIdResolver()
          Same as SSISystemIdResolver(null, null, null)
SSISystemIdResolver(String includingFilePath)
          Same as SSISystemIdResolver(parentFilePath, null, null)
SSISystemIdResolver(String includingFilePath, ResourceLoader resourceLoader, XMLCDeferredParsingFactory factory)
           
 
Method Summary
 String getSystemId(String includingFileSystemId, String ssiPath)
           
(package private)  void setSsiBase(String ssiBase)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSISystemIdResolver

public SSISystemIdResolver()
Same as SSISystemIdResolver(null, null, null)

SSISystemIdResolver

public SSISystemIdResolver(String includingFilePath)
Same as SSISystemIdResolver(parentFilePath, null, null)
Parameters:
includingFilePath - the relative (to a context, such as class loader, reparse resource dir, servlet context, etc...) path of the including, or parent, file with any directories in the path separated by '/', optional, may be null

SSISystemIdResolver

public SSISystemIdResolver(String includingFilePath,
                           ResourceLoader resourceLoader,
                           XMLCDeferredParsingFactory factory)
Parameters:
includingFilePath - the relative (to a context, such as class loader, reparse resource dir, servlet context, etc...) path of the including, or parent, file with any directories in the path separated by '/', optional, may be null
resourceLoader - a resource loader, allows for pluggable control over loading SSI resources, optional, may be null
factory - the XMLC deferred parsing factory, used to obtain paths from package prefixes when a ResourceLoader is also provided, optional, may be null
Method Detail

setSsiBase

void setSsiBase(String ssiBase)

getSystemId

public String getSystemId(String includingFileSystemId,
                          String ssiPath)
                   throws IOException
Parameters:
includingFileSystemId - the fully qualified path of the including file
ssiPath - the path declared in the server-side-include directive
Returns:
the resolved fully qualified path of the server-side-include
Throws:
IOException - if unable to resolve the server-side-include path
NullPointerException - if either argument is null


Copyright © 1999-2007 enhydra.org (Mark Diekhans, David Li, Richard Kunze, Jacob Kjome). All Rights reserved.