Re: Calling a different stylesheet based upon XML tag?
Robert Koberg wrote: >This is pretty easy in XSL. You just need to apply templates on the >source and catch the elements with template matches. You could do >something like: > ><!-- router.xsl --> ><xsl:import href="order.xsl"/> ><xsl:import href="bill.xsl"/> > ><xsl:template match="/rootElem"> > <xl:apply-templates/> ></xsl:template> > ><!-- order.xsl --> ><xsl:template match="Order"> >... do order processing... ></xsl:template> > ><!-- bill.xsl --> ><xsl:template match="Bill"> >... do bill processing... ></xsl:template> > >best, >-Rob I understand how to do that, but I was hoping not to have to go that route. See at the moment I have a file like order.xslt and within it there is a a template match="Address" with a set of instructions. I also have a file like bill.xslt and within it there is also a template match="Address" with a different set of instructions. I am using a creating a web service that take in XML converts to a string, processes it and gets a return string, which I then reconvert to XML. This is part of my requirement, so that can't change. In order to keep the web service generic, I'd like to be able to always direct it to one xslt driver file for the input and one xslt driver file for the output based upon what program/system I need to transform for. Since I am playing middle man to help interface between too systems. Multiple transactions may have the address tag on it, but each one needs to transform it differently to the string. And then transform it back on the output. Thus, I've built an input and output xslt for each transaction I want to enable. The input xslt uses template matching, as I have understood it to be the fastest xslt processing. The output xslt uses template names and call-template in order to place everything in the correct order. The use of template match and name are to facilitate use of a database to automatically regenerate the xslt files as needed. Is there a way to create an input driver xslt file and an output xslt driver file where it either includes just the one set of templates I need at run time. Or where it can point the text to transform to the correct file? Thank you! Becky
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format