RE: [xsl] Process output from imported stylesheet?

Subject: RE: [xsl] Process output from imported stylesheet?
From: "Magnus Teo" <magnusteo@xxxxxxx>
Date: Thu, 11 Mar 2004 16:18:18 +0800
so your included/imported file would have to be complete before the stylesheet was compiled.
- ugh, bummer. Thanks Josh.

You could use a two pass approach, where you generate the XSL in the first pass, and then use the generated XSL file to process your XML.
- I'm letting my users process their XML data through a library of XSLs, this being one of them and the wish was to let them select which elements to avail and order of appearance. If I generate a unique XSL for each of the users, it may be unmanageable to add new features in the future. =\

Perhaps if you provide an example of the problem you are trying to solve someone could help with an alternative to dynamic call-templates?
- Alright, here are very brief extracts of the various files involved, please pardon any errors.

- Primary XML file where the contents to be manipulated are.
<?xml version="1.0" encoding="UTF-8"?>
<Test xmlns="http://www.test.test"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="../xmls/test.xsd">
<Content genre="Entries List">
<Section ID="0000000005">
<DocID>2</DocID>
<Author>magnus</Author>
<Title>violin..</Title>
<Desc>and this would be the &amp;lt;strong&amp;gt;second&amp;lt;/strong&amp;gt;...</Desc>
<DateCreated>2004-02-10 03:03:26</DateCreated>
<DateModified>2004-02-10 03:03:26</DateModified>
<DatePublished>2004-02-29 12:00:00</DatePublished>
</Section>
<Section ID="0000000039">
<DocID>2</DocID>
<Author>magnus</Author>
<Title>A super getChronInfo function</Title>
<Desc>new url sucks, I feel like sleeping.. x_X</Desc>
<DateCreated>2004-02-09 00:21:17</DateCreated>
<DateModified>2004-02-09 03:01:08</DateModified>
<DatePublished>2004-02-10 00:21:17</DatePublished>
</Section>
</Content>
</Test>


- Secondary XML file where settings of which elements to display are.
<?xml version="1.0" encoding="UTF-8"?>
<Test xmlns="http://www.test.test";>
	<Content genre="Some config">
		<Order>
			<Element>Title</Element>
			<Element>DatePublished</Element>
			<Element>Desc</Element>
			<Element>DateModified</Element>
			<Element>Author</Element>
		</Order>
	</Content>
</Test>


- Original Primary XSL which predetermines template order <xsl:template match="base:Section"> <xsl:call-template name="Title" /> <xsl:call-template name="DatePublished" /> <xsl:call-template name="Desc" /> <xsl:call-template name="DateModified" /> <xsl:call-template name="Author" /> <xsl:call-template name="Divider" /> </xsl:template>


- Secondary XSL to process the elements desired and its order.
<xsl:template match="/">
<xsl:element name="xsl:template">
<xsl:attribute name="match">base:Section</xsl:attribute>
<xsl:for-each select="document(Secondary XML as above)/*/*/*/base:Element">
<xsl:element name="xsl:call-template">
<xsl:attribute name="name"><xsl:value-of select="." /></xsl:attribute>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
- And this secondary XSL was imported into the orignal primary XSL, amending the above..
<xsl:template match="base:Section">
<xsl:apply-imports />
</xsl:template>


_________________________________________________________________
Find gifts, buy online with MSN Shopping. http://shopping.msn.com.sg/


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread