[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] dynamically extending xslt
Subject: Re: [xsl] dynamically extending xslt From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 10 Oct 2005 14:07:41 +0100 |
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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] dynamically extending xsl, David Carlisle | Thread | [xsl] Getting inner exception in xs, omprakash . v |
Re: [xsl] dynamically extending xsl, David Carlisle | Date | [xsl] Getting inner exception in xs, omprakash . v |
Month |