diff --git a/make-includes/build_misc_rules.make b/make-includes/build_misc_rules.make index bd48b3b..37bbda6 100755 --- a/make-includes/build_misc_rules.make +++ b/make-includes/build_misc_rules.make @@ -65,6 +65,21 @@ endif +# +# List of XSL stylesheets. If any of these change, we need to rebuild +# everything. +# +# We can't use the resolver approach under Windows because of the DOS +# pathnames. The style sheets come out of the resolver with paths like +# C:\bar\foo\..., and make interprets the colon as an extra dependency +# delimiter (tested and behaviour verified). Of course, this works fine on +# any platform with sensible path standards. Quoting the value doesn't +# help, unfortunately. Bugger :( +# +#XSLT_STYLESHEETS:=$(shell java org.apache.xml.resolver.apps.resolver -u file:///xml2html.xsl uri | ( grep 'Result: file:' || echo '::xml2html.xsl' ) | cut -d':' -f3-) $(shell java org.apache.xml.resolver.apps.resolver -u file:///xml2latex.xsl uri | ( grep 'Result: file:' || echo '::xml2latex.xsl' ) | cut -d':' -f3-) +XSLT_STYLESHEETS:=$(TEACHING_SHARED)/Authoring/XML/xml2html.xsl $(TEACHING_SHARED)/Authoring/XML/xml2latex.xsl + + ################################################################################ # # Add standard file suffixes. @@ -192,6 +207,27 @@ ################################################################################ # +# Generate the derived XML source from the original XML template. +# This is done by simply running the original source through xmllint +# with the --xinclude option to process all the xi:include elements. +# The result of this could have just been piped into the XSLT processor, +# except that (a) not all of the processors support input from stdin, +# and (b) combining both xmllint and XSLT processing into one command +# means that make won't stop if there's any errors from xmllint. +# +# Sed is used to add a comment to the derived XML file, warning that this +# is generated and shouldn't be edited. Sed was used because the +# processing instruction MUST be on the first line. The implication here +# is that all input source files have an processing instruction +# (which they should anyway). +# +$(DERIVED_XML): $(SOURCE_XML) $(XSLT_STYLESHEETS) + xmllint --xinclude $< >$@ + @sed -i -e '1a ' $@ + + +################################################################################ +# # Build the test document. # test: test.pdf