<?xml version="1.0" standalone="yes" ?>
<project name="SimplifiedICSR" default="default">
	<description>Ant Build file for the XFeature test -- SimplifiedICSR</description>

	<property name="MetaModel" location="SimplifiedICSR.xfmm" />
	<property name="DisplayModel" location="SimplifiedICSR.xdm" />
	<property name="GeneralFiles" location="../general_files" />
	
	<target name="default">
		<echo>Test the SimplifiedICSR sample configuration</echo>
		<ant target="ValidateFeatureMetaModel" antfile="build.xml" dir="${GeneralFiles}" inheritall="false">
			<property name="MetaModel" location="SimplifiedICSR.xfmm" />
			<property name="DisplayModel" location="SimplifiedICSR.xdm" />
			<property name="TmpLoc" location="tmp"/>
		</ant>
	</target>
	
	<target name="generate">
		<ant target="clean"/>
		<fail unless="FamilyXFM" message="The XSD Application Generator: Family model filename has to specified." />
		<fail unless="FamilyXDM" message="The XSD Application Generator: Family display model filename has to specified." />
		<fail unless="AppXFMM" message="The XSD Application Generator: Filename of the application meta-model has to specified." />
		<fail unless="AppXDM" message="The XSD Application Generator: Filename of the application display model has to specified." />
		<fail unless="TmpLoc" message="The XSD Application Generator: Temp directory not specified." />
		<ant target="GenerateApplicationSchema"/>
		<ant target="GenerateAndCheckDisplayModel"/>
		<ant target="clean"/>
	</target>
	
	<target name="GenerateApplicationSchema" description="Generates the application metamodel (*.xfmm) from family model (*.xfm).">
		<xmlvalidate file="${FamilyXFM}" lenient="false" failonerror="true" warn="true">
          <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
		  <attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
		</xmlvalidate>
		<xslt force="true" style="SimplifiedIcsrXfmmGenAddUniqueNames.xsl" in="${FamilyXFM}" out="${TmpLoc}/xfmAddUniqueNames.xfm">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>
		<xslt force="true" style="SimplifiedIcsrXfmmGen.xsl" in="${TmpLoc}/xfmAddUniqueNames.xfm" out="${AppXFMM}">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>
	</target>

	<target name="GenerateAndCheckDisplayModel" description="Generates the application display model (*.xdm) from family display model (*.xdm) and family meta-model (*.xfmm). Then it checks that the generated display model is complete.">
		<xslt force="true" style="SimplifiedIcsrXdmGen.xsl" in="${FamilyXDM}" out="${TmpLoc}/xfmm2xdm.xsl">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>
		<xslt force="true" style="${TmpLoc}/xfmm2xdm.xsl" in="${AppXFMM}" out="${AppXDM}">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>			
		<xslt force="true" style="${GeneralFiles}/DisplayModelCompiler.xsl" in="${AppXFMM}" out="${TmpLoc}/DisplayModelVerifier.xsl">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>			
		<xslt force="true" style="${TmpLoc}/DisplayModelVerifier.xsl" in="${AppXDM}" out="${TmpLoc}/DisplayModelVerificationResults.txt">
			<factory name="net.sf.saxon.TransformerFactoryImpl"/>
		</xslt>			
		<echo message="MESSAGE: The verification results are written to file 'DisplayModelVerificationResults.txt'"/>
	</target>
	
	<target name="clean">
		<delete file="${TmpLoc}/DisplayModelVerifier.xsl"/>
		<delete file="${TmpLoc}/xfmAddUniqueNames.xfm"/>
		<delete file="${TmpLoc}/xfmm2xdm.xsl"/>
		<delete file="${TmpLoc}/xfmMacroProcessing.xfm"/>
	</target>	
	
</project>

