You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by pe...@seittipaja.fi on 2001/06/10 19:13:34 UTC

Processing XSL dynamically created with XSLT

Hi from a cocoon-users newbie --

Is it possible to use Cocoon to generate an XSL stylesheet with an XSLT 
(not XSP), and reapply this dynamically generated stylesheet to the 
source document?

I'm not talking about normal stylesheet chaining; in this case, the 
second stylesheet would be a "virtual," dynamically generated one, and 
not one residing statically in a file.

--

Background info for the real angels -- just in case one of my previous 
approaches is workable after all:

I'm working on a project where I need to include data from a source file 
the structure of which is determined at run-time (from another file). 
Since I can't generate xpath expressions dynamically at run-time, I'm 
trying to do this by processing a dynamically generated stylesheet with 
the paths. I've tried two approaches and run into brick walls:

(1)	Use an XSLT on the structure file to a file something like this:

<document>
	<data> <!-- from src.xml with document() function -->
	.
	.
	.
	</data>
	<xsl:stylesheet>
		.
		(generated templates)
		.
	</xsl:stylesheet>
</document>

The problem is that Xalan places the xmlns:xsl declaration at the 
<document> element -- and then doesn't process the embedded stylesheet's 
templates. (Only {this/kind/of} expression does work.) If I copy the 
output and manually move the xmlns:xsl declaration to the xsl:stylesheet 
element, everything is fine. However, I haven't discovered a way to do 
this dynamically. Folks on the Mulberry XSL list tell me that this is a 
bug; the generated stylesheet should work.

(2)	Use an XSLT (with namespace aliasing) on the structure file to 
generate a stylesheet that processes itself, retrieving the data with 
the document() function, and renders HTML.

However, strangely enough, the document() function will retrieve nothing 
at all, iff invoked from within (a) a stylesheet that processes itself 
or (b) a stylesheet embedded in XML. Boom, another brick wall. (Any idea 
if this is a bug or a feature?)

Now, I'd like to try a third approach: generating a stylesheet with an 
XSLT, and transforming the source document *again* with the generated 
sheet.

Any ideas how this could be done?

Best regards,

Petteri Sulonen

(Std. disclaimer: I did my best to look in the FAQ, the Mulberrytech and 
Cocoon-users mailing list archives, and didn't find anything directly 
related to this. Apologies if it has been addressed before.)


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>