I want to apply templates to some xml that my xsl has genera

Here should go questions about transforming XML with XSLT and FOP.
weston
Posts: 4
Joined: Sat Sep 23, 2006 8:23 pm

I want to apply templates to some xml that my xsl has genera

Post by weston »

Here is my template for processing this data:

<Data>("Apr","1","2");("Ma""y","1","2");("Jun""","1","2";("Jul,05","2","2");(Aug,"45","76");("Sep","3","2");("Oct","1","2");("Nov","1","2");("Dec","1","2")</Data>


<xsl:template name="ParseData">
<xsl:call-template name="CSVProcess_String">
<xsl:with-param name="String"><xsl:value-of select="$RawData"/></xsl:with-param>
<xsl:with-param name="SubNodeName">row</xsl:with-param>
<xsl:with-param name="Delimiter">;</xsl:with-param>
<xsl:with-param name="QuoteChar">#</xsl:with-param>
</xsl:call-template>
</xsl:template>

this outputs:

<?xml version="1.0" encoding="utf-8"?>
<root>
<dataset>
<row>("Apr","1","2")</row>
<row>("Ma""y","1","2")</row>
<row>("Jun""","1","2"</row>
<row>("Jul,05","2","2")</row>
<row>(Aug,"45","76")</row>
<row>("Sep","3","2")</row>
<row>("Oct","1","2")</row>
<row>("Nov","1","2")</row>
<row>("Dec","1","2")</row>
</dataset>
</root>


But I then want to do template matching on this data, i.e. the same thing for every row.

I'm sure it's simple but I'm new to all this and not sure what to search for even.

Thanks in advance,

Alan
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi Alan,

You can direct all the output in a variable if the output is generated inside an xsl:variable element. For instance

<xsl:variable name="test">
<xsl:apply-templates/>
</xsl:variable>

will place everything generated by the apply-templates inside the test variable.
In XLT 1.0 what will be in the variable will be a result tree fragment. You need to convert that to a node set using your processor node-set extension and then you will be able to apply templates on those nodes with something like

<xsl:apply-templates select="$testNodeSet"/>

You can also have two transformations for this, note that oXygen allows you to define more XSLT stylesheets for a transformation scenario. Also the JAXP API allows you to specify more stylesheets when you do a transformation.

Best Regards,
George
weston
Posts: 4
Joined: Sat Sep 23, 2006 8:23 pm

Post by weston »

Cheers for that!
Post Reply