Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 07:08 AM
Petterson Mikael
Guest
 
Posts: n/a
Default How generate one file for each class in xml using xslt and java?

Hi,

I have one xml file with many class elements. For each class element I
need to generate a new new java file.As it is now I get ( my output )
all classes in one file. Do I control this in the code for the
transformer or in the xsl-template? Where can I find information about
this?

Your help is very much appreciated,

//Mikael
  #2  
Old July 20th, 2005, 07:09 AM
ted
Guest
 
Posts: n/a
Default Re: How generate one file for each class in xml using xslt and java?

Take a look at the Saxon parser. It processes the <xsl:result-document>
element which will output to multiple documents.

Put something like this in your xsl:

<xsl:for-each select="yourClass">
<xsl:variable name="fileName" select="concat(@className, '.java')">
<xsl:result-document href="$fileName">
<!-- put your Java code here -->
</xsl:result-document>
</xsl:for-each>



"Petterson Mikael" <mikael.petterson@era.ericsson.se> wrote in message
news:3F5D7C58.900AC05D@era.ericsson.se...[color=blue]
> Hi,
>
> I have one xml file with many class elements. For each class element I
> need to generate a new new java file.As it is now I get ( my output )
> all classes in one file. Do I control this in the code for the
> transformer or in the xsl-template? Where can I find information about
> this?
>
> Your help is very much appreciated,
>
> file://Mikael[/color]


  #3  
Old July 20th, 2005, 07:09 AM
ted
Guest
 
Posts: n/a
Default Re: How generate one file for each class in xml using xslt and java?

I forgot to close the <xsl:variable> element. It should be:

<xsl:variable name="fileName" select="concat(@className, '.java')"/>



"ted" <tedNOSPAM94107@yahoo.com> wrote in message
news:hUV7b.7385$PE6.4278@newsread3.news.pas.earthl ink.net...[color=blue]
> Take a look at the Saxon parser. It processes the <xsl:result-document>
> element which will output to multiple documents.
>
> Put something like this in your xsl:
>
> <xsl:for-each select="yourClass">
> <xsl:variable name="fileName" select="concat(@className, '.java')">
> <xsl:result-document href="$fileName">
> <!-- put your Java code here -->
> </xsl:result-document>
> </xsl:for-each>
>
>
>
> "Petterson Mikael" <mikael.petterson@era.ericsson.se> wrote in message
> news:3F5D7C58.900AC05D@era.ericsson.se...[color=green]
> > Hi,
> >
> > I have one xml file with many class elements. For each class element I
> > need to generate a new new java file.As it is now I get ( my output )
> > all classes in one file. Do I control this in the code for the
> > transformer or in the xsl-template? Where can I find information about
> > this?
> >
> > Your help is very much appreciated,
> >
> > file://Mikael[/color]
>
>[/color]


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles