Re: [xsl] Template to return XML

Subject: Re: [xsl] Template to return XML
From: Mukul Gandhi <mukulgw3@xxxxxxxxx>
Date: Fri, 17 Oct 2003 00:45:17 -0700 (PDT)
Hi Karl,
   I have written the following XSL to illustrate the
concept --

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="http://xml.apache.org/xalan";>
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>
	
<xsl:template match="/A">
    <xsl:variable name="var">
	<xsl:call-template name="get-subset-xml">
	   <xsl:with-param name="param" select="child::B"/>
	</xsl:call-template>
    </xsl:variable>
		
    <!-- using variable var -->
    <xsl:value-of
select="count(xalan:nodeset($var)/B/*)" />
		
</xsl:template>
	
<xsl:template name="get-subset-xml">
   <xsl:param name="param"/>
     <xsl:copy-of select="$param"/>
</xsl:template>
	
</xsl:stylesheet>

A nodeset function is being used, *to use the Result
Tree Fragment(RTF), returned by the template
"get-subset-xml" *. I have used nodeset, for
illustration purpose..

I hope the explanation is useful..

Regards,
Mukul

--- "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>
> 
> 
> 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
> 
> 
>  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