Guest towi Posted October 6, 2005 Share Posted October 6, 2005 Hi,I am quite new to XSLT, but got quite far, I think. Now I have a working XSLT and want to transform "MyOwn" XML to (for example) HTML. Alas, in "MyOwn" XML some blocks are listed before the main stuff, and I want to appear it at the end of the HTML.So, basically my input is: <Report> <Matrix name="U-Matrix"> ... </Matrix> <Matrix name="E-Matrix"> ... </Matrix> <FileByFile> <FromFile name="File1"> ... </FromFile> <FromFile name="File2"> ... </FromFile> </FileByFile></Report> I have two templates, one for "Matrix", and one for the "FromFile". <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"><body> <xsl:apply-templates /> </body></html></xsl:template><xsl:template name="file_x_file" match="FromFile"> <table border="1"> ... </table></xsl:template><xsl:template name="matrices" match="Matrix"> <table border="1"> ... </table></xsl:template> So, because in the input "Matrix" appears before the "FromFiles" this is the case in the output, too.Question: How can I force the "Matrix"s to the end of the output?Thanks in advance,tschau, towi. Link to comment Share on other sites More sharing options...
dooberry Posted November 25, 2005 Share Posted November 25, 2005 With apply-templates, you can choose the order in which they appear. <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"><body> <xsl:apply-templates select="FromFile" /> <xs:apply-templates select="Matrix" /> </body></html></xsl:template><xsl:template match="FromFile"> <table border="1"> ... </table></xsl:template><xsl:template match="Matrix"> <table border="1"> ... </table></xsl:template> I think this will do it, you don't actually need to name the templates to apply them, I'm not sure if you would need to change the reference in the apply-templates tag to the template name if you needed to use the template names for another reason.I've played around with this myself and it works in IE, but let me know if you run into any problems.Dooberry Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now