How generate one file for each class in xml using xslt and java?

  • Thread starter Petterson Mikael
  • Start date
P

Petterson Mikael

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
 
T

ted

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

ted

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top