Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to apply two XSL transformations to one XML file

Reply
Thread Tools

how to apply two XSL transformations to one XML file

 
 
Franck Perrin
Guest
Posts: n/a
 
      07-14-2003
I'd like to know if there is a way to apply to successive XSL
transformations on one XML file.

I got this XML file :
<page Action="N047">
<data defaultName="c0dos010" Type="String" CustomName=""/>
<data defaultName="clxc0233" Type="String" CustomName="EndDate"/>
</page>

I want to generate java code like this :

************************************************** ****************************
package cnaf.param ;
import cnaf.framework.cnafdate.*;
import cnaf.framework.services.*;

public class N047
{
private static final String NCC = N047.class.getName();
private String c0dos010;
private String EndDate;

public N047() //constructeur
{}
public void setc0dos010 (String value)
{c0dos010=value;}
public String getc0dos010()
{return c0dos010;}
public void setEndDate (String value)
{EndDate=value;}
public String getEndDate()
{return EndDate;}
************************************************** ****************************

I wrote this XSL code :

------------------------------------------------------------------------------
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
xmlnsslscr="http://www.w3.org/TR/WD-xsl" version="1.0">
<xslutput method="text"/>
<xsl:template match="page">


package cnaf.param ;
import cnaf.framework.cnafdate.*;
import cnaf.framework.services.*;

public class <xsl:value-of select="@Action"/>
{

private static final String NCC = <xsl:value-of
select="@Action"/>.class.getName();
<xsl:for-each select="data">
<xsl:variable name = "PropName">
<xsl:choose>
<xsl:when test="@CustomName!=''">
<xsl:value-of select="@CustomName"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="@defaultName"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name = "type">
<xsl:choose>
<xsl:when test="@Type != ''">
<xsl:value-of select="@Type"/>
</xsl:when>
<xsltherwise>String</xsltherwise>
</xsl:choose>
</xsl:variable>
private <xsl:value-of select="$type" /><xsl:text> </xsl:text>
<xsl:value-of select="$PropName" />;
</xsl:for-each>

public <xsl:value-of select="@Action" />() //constructeur
{
}
<xsl:for-each select="data">

<xsl:variable name = "PropName">
<xsl:choose>
<xsl:when test="@CustomName!=''">
<xsl:value-of select="@CustomName"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="@defaultName"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name = "type">
<xsl:choose>
<xsl:when test="@Type != ''">
<xsl:value-of select="@Type"/>
</xsl:when>
<xsltherwise>String</xsltherwise>
</xsl:choose>
</xsl:variable>

public void set<xsl:value-of select="$PropName" /> (<xsl:value-of
select="$type" /> value)
{<xsl:value-of select="$PropName" />=value;}

public <xsl:value-of select="$type" /> get<xsl:value-of
select="$PropName" />()
{return <xsl:value-of select="$PropName" />;}
</xsl:for-each>
}
</xsl:template>
</xsl:stylesheet>
------------------------------------------------------------------------------

But definition of variables "PropName" and "type" are declared twice.
If I could produce a intermediate XML file like this :
<page Action="N047">
<data PropName="c0dos010" Type="String"/>
<data PropName="EndDate" Type="String"/>
</page>
I wouldn't be oblige to declare variables twice because I would have
controled the value of the attributes as I generate the temporary XML
file.

The problem is that I can't find how to do what I want.
Is there anybody who can help me?
 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Miscellaneous issues with tex4ht, xml and xsl transformations Geico Caveman XML 0 10-02-2008 06:34 PM
DocBook custom XSL transformations Szymon Nieradka XML 4 05-13-2006 12:16 AM
XSLT question related to <xsl:template> and <xsl:apply-templates> Vijay singh XML 1 11-04-2004 03:42 PM
sorting <xsl:for-each> versus <xsl:apply-templates> Sparko XML 0 07-09-2004 09:03 AM
Performance of Xsl Transformations George Durzi ASP .Net 1 12-31-2003 05:58 PM



Advertisments