Re: dynamically extending xslt
Hi Marco, > we are developing a new correspondence-system based on XML. Our DTD > is very similar to XHTML with some additional structures like > selections, iterations and variableplaceholders. The composition of > these documents will be realized as a XSLT-stylesheet. I wrote a > stylesheet wich transforms a document into a XSLT-stylesheet. This > (produced) stylesheet will be used on a XML-file containing the > variablevalues and the data needed to resolve the logical structures > (e.g. selections etc.). [snip] > After this transformation the user is able to add another "topic" to > the document, which could contain another selection. And I need this > new content executed, after it is transformed into xslt. I call the kinds of documents that you're using here "document templates". Instead of doing: your stylesheet | v document --> (transform) --> XSLT template stylesheet | v data --> (transform) --> final result you might be able to get away with the slightly simpler process: your stylesheet | v data --> (transform) --> final result ^ | document template In other words, use both the document template and the XML data as inputs to the same stylesheet, and use them in conjunction to create the final output that you're after. Your stylesheet would contain something like: <!-- Global variables for access to data and document template --> <xsl:variable name="data" select="/" /> <xsl:variable name="template" select="document('template.xml')" /> <!-- Apply templates to the template to get the result --> <xsl:template match="/"> <xsl:apply-templates select="$template" /> </xsl:template> <!-- Identity template to copy through everything by default --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> <!-- Templates to pick up on the "instructions" in your document template and use values from the data XML to resolve them --> <xsl:template match="selection"> <xsl:variable name="variable" select="@variable" /> <xsl:variable name="value" select="$data//variable[@name = $variable]" /> <xsl:apply-templates select="item[@value = $value]/node()" /> </xsl:template> ... This way, people could edit and re-edit the document template without having to worry about updating any stylesheets. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
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