Subject: Re: [xsl] Template to return XML From: Armen Martirossian <armmarti@xxxxxxxxx> Date: Fri, 17 Oct 2003 03:35:33 -0700 (PDT) |
--- "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxx> wrote: > Hello, > > I need a template to return a subset of XML from the > xml source. I'm trying > to populate a variable with this information. How > can I do this? > Example: > > <A> > <B> > <ASDF/> > <QWEA/> > <FEASI/> > </B> > <C/> > </A> > In XSLT there is no equivalent of "return" as in conventional languages. > > So, a template that will return (as an example) <B> > and its subset of data. > Something like > > <xsl:template name="get_subset_xml"> > .... select the <b> node > </xsl:template> > > More importantly, how do I assign a variable to this > new subset? > So: > > <xsl:variable name="some_subset" > select="get_subset_xml"/> > > where $some_suset is: > <B> > <ASDF/> > <QWEA/> > <FEASI/> > </B> > > > Is this possible? > Karl It's possible, of course. If you want to use named template to fetch the subset, you must wrap the template call by xsl:variable, like this: <xsl:variable name="subset"> <xsl:call-template name="get_subset_xml"/> </xsl:variable> Then you'll be able to retrieve the value by converting the temporary tree to nodeset(some XSLT processors explicitly perform the conversion, e.g., Saxon) by using EXSLT's node-set() function or something similar(about all XSLT processors have such kind of extension function). But there is a simpler way to retrieve the subset without calling a template; just write: <xsl:variable name="subset" select="/A/B"/> Regards, Armen > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] “ Entity reference , Abhijit Junnare | Thread | Re: [xsl] Template to return XML, Karl J. Stubsjoen |
RE: [xsl] generate XHTML header wit, Jarno . Elovirta | Date | RE: [xsl] Special symbols in XML th, Michael Kay |
Month |