diff --git a/make-includes/xslt_functions.make b/make-includes/xslt_functions.make index fdcbeed..d7cff88 100755 --- a/make-includes/xslt_functions.make +++ b/make-includes/xslt_functions.make @@ -16,6 +16,49 @@ ################################################################################ # +# Resolve a URI for some XML entity such as a stylesheet into a path to +# the actual item. This works by calling the example resolver application +# that comes with the entity resolver, then extracting the full path from +# the result. If the URI cannot be resolved, the function returns the +# original filename so that the XSLT processor can fail with a meaningful +# error message. +# +# This is a workaround for the mysterious breakage that occured on Nigel's +# machine in early 2006 where all of the XSLT processors suddenly stopped +# accepting resolver class names as command line arguments. +# +# This approach, while apparently kludgey, does have a particular +# advantage, however, in that it can be used with non-Java based XSLT +# processors such as Xalan C++, whereas the previous approach only worked +# with Saxon and Xalan-J. In other words, this will work with ANY XSLT +# processor. +# +# Note that the function adds the "file:///" protocol to the front of the +# argument, so callers should NOT add this themselves! +# +# For reference, the typical output from the resolver application looks +# something like this for a successful resolution: +# +# % java org.apache.xml.resolver.apps.resolver -u file:///foo.xsl uri +# Resolve URI (uri): +# uri: file:///foo.xsl +# Result: file:/path/to/item/foo.xsl +# +# and like this for a failure: +# +# % java org.apache.xml.resolver.apps.resolver -u file:///missing.xsl uri +# Resolve URI (uri): +# uri: file:///missing.xsl +# Result: null +# +# Arguments: +# $(1) file name of item to be resolved, WITHOUT the "file:///" +# +resolve_uri = `java org.apache.xml.resolver.apps.resolver -u file:///$(1) uri | ( grep 'Result: file:' || echo '::$(1)' ) | cut -d':' -f3` + + +################################################################################ +# # Pass stylesheet parameters as appropriate to the XSLT processor. # $(XSLT) should be either defined as an environment variable, or # passed in as a parameter to make. @@ -62,20 +105,28 @@ # # Xalan-C # -xalanc = Xalan $(3) $(4) $(5) $(6) $(7) $(8) $(1) $(2) +# xalanc = Xalan $(3) $(4) $(5) $(6) $(7) $(8) $(1) $(2) +# +xalanc = Xalan $(3) $(4) $(5) $(6) $(7) $(8) $(1) $(call resolve_uri,$(2)) # # Xalan-J # -xalanj = xalan -in $(1) -xsl $(2) $(3) $(4) $(5) $(6) $(7) $(8) +# xalanj = xalan -in $(1) -xsl $(2) \ +# -uriresolver org.apache.xml.resolver.tools.CatalogResolver \ +# $(3) $(4) $(5) $(6) $(7) $(8) +# +xalanj = xalan -in $(1) -xsl $(call resolve_uri,$(2)) $(3) $(4) $(5) $(6) $(7) $(8) # # SAXON # -saxon = saxon -x org.apache.xml.resolver.tools.ResolvingXMLReader \ - -y org.apache.xml.resolver.tools.ResolvingXMLReader \ - -r org.apache.xml.resolver.tools.CatalogResolver \ - $(1) file:///$(2) $(3) $(4) $(5) $(6) $(7) $(8) +# saxon = saxon -x org.apache.xml.resolver.tools.ResolvingXMLReader \ +# -y org.apache.xml.resolver.tools.ResolvingXMLReader \ +# -r org.apache.xml.resolver.tools.CatalogResolver \ +# $(1) file:///$(2) $(3) $(4) $(5) $(6) $(7) $(8) +# +saxon = saxon $(1) $(call resolve_uri,$(2)) $(3) $(4) $(5) $(6) $(7) $(8) ################################################################################