Subject: RE: [xsl] Process output from imported stylesheet? From: "Josh Canfield" <Josh.Canfield@xxxxxxxxxxxx> Date: Thu, 11 Mar 2004 11:02:20 -0800 |
Do you need to call template for each element? Why not use a template match? You could iterate over the users config elements and apply templates on the elements from the source document. Something like this: <xsl:variable name="config" select="document('2.xml')"/> <xsl:template match="/"> <xsl:apply-templates select="Test/Content/Section"/> </xsl:template> <xsl:template match="Section"> <section> <xsl:variable name="section" select="."/> <xsl:for-each select="$config/Test/Content/Order/Element"> <xsl:apply-templates select="$section/*[name()=current()]"/> </xsl:for-each> </section> </xsl:template> I did this with no regard for your namespaces... Josh -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Magnus Teo Sent: Thursday, March 11, 2004 12:18 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Process output from imported stylesheet? >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 &lt;strong&gt;second&lt;/strong&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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Process output from impor, Magnus Teo | Thread | [xsl] Is exclude-result-prefixes wi, James J. Ramsey |
RE: [xsl] mediaobject on titlepage, Schreifels, Mark J. | Date | RE: [xsl] Embedding html within xml, Josh Canfield |
Month |