xslt generation guidance

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

xslt generation guidance

Joseph L. Casale

I have a need where by an single xslt and xml file will need to generate output

to multiple files indicated by the presence of individual elements in the xml.

 

For example, the xml would be:

 

<root>

    <elemA foo=”a”/>

    <elemB foo=”b”/>

</root>

 

So, the output files would be “a.cs” and “b.cs”.

 

Is this possible? If not, can I invoke the parser with multiple command line

parameters to be passed into a single template?

Thanks,

jlc


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: xslt generation guidance

Martin Honnen-2
Joseph L. Casale wrote:

> I have a need where by an single xslt and xml file will need to generate
> output
>
> to multiple files indicated by the presence of individual elements in
> the xml.
>
> For example, the xml would be:
>
> <root>
>
>      <elemA foo=”a”/>
>
>      <elemB foo=”b”/>
>
> </root>
>
> So, the output files would be “a.cs” and “b.cs”.
>
> Is this possible?

With Saxon 9 and XSLT 2.0, yes, of course

<xsl:template match="/">
   <xsl:apply-templates select="//@foo" mode="doc"/>
</xsl:template>

<xsl:template match="@foo" mode="doc">
   <xsl:result-document href="{.}.cs">
     <!-- now produce content of file here -->
   </xsl:result-document>
</xsl:template>

The mode is not necessarily needed but it might be safer doing it in a
separate mode if you want to use the default mode to process other nodes.

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Reply | Threaded
Open this post in threaded view
|

Re: xslt generation guidance

Joseph L. Casale
Martin Honnen wrote:

> With Saxon 9 and XSLT 2.0, yes, of course
>
> <xsl:template match="/">
>    <xsl:apply-templates select="//@foo" mode="doc"/>
> </xsl:template>
>
> <xsl:template match="@foo" mode="doc">
>    <xsl:result-document href="{.}.cs">
>      <!-- now produce content of file here -->
>    </xsl:result-document>
> </xsl:template>
>
> The mode is not necessarily needed but it might be safer doing it in a
> separate mode if you want to use the default mode to process other nodes.

Much appreciated, that actually answered a few other questions as well.

Thank you,
jlc

------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help