473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to apply two XSL transformations to one XML file

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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xslscr="http://www.w3.org/TR/WD-xsl" version="1.0">
<xsl:output 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>
<xsl:otherwise>
<xsl:value-of select="@defaultName"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name = "type">
<xsl:choose>
<xsl:when test="@Type != ''">
<xsl:value-of select="@Type"/>
</xsl:when>
<xsl:otherwise>String</xsl:otherwise>
</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>
<xsl:otherwise>
<xsl:value-of select="@defaultName"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name = "type">
<xsl:choose>
<xsl:when test="@Type != ''">
<xsl:value-of select="@Type"/>
</xsl:when>
<xsl:otherwise>String</xsl:otherwise>
</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?
Jul 20 '05 #1
0 1752

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike | last post by:
I am trying to code vb.net to perform XML transformations by applying a style sheet to a XML doc. All of my XML and XSLT documents will be in either XML DOM Objects or string variables. I am not...
5
by: Keith Chadwick | last post by:
I am migrating an existing ASP app that uses XSLT transformations to render against a language XML doc for localization and other items. When I moved this logic into .NET and the native xml and xsl...
1
by: Chris | last post by:
I am doing a little research into the xml web server control and in particular the ability to do transformations with it. However all's I can see is the ability to feed in from an actual xml file....
6
by: Christopher | last post by:
I am currently in the process of evaluating the performance hits of moving to the .NET platform for our application. I created a sample project that loads the transforms the same XML and XSLT in...
1
by: George Durzi | last post by:
Folks, I'm running into some performance issues with my Xsl transformations. I've done a ton of debugging and digging around, and have come to the conclusion that the performance issues are NOT...
0
by: GSK | last post by:
I notice that when working with a medium sized XML file, (a few hundred K), that contains maybe a couple of hundred nodes, that it takes quite a while to transform the document using an XSL...
0
by: Alain Frisch | last post by:
Hello, I'd like to announce a new small language for XML transformation, called XStream. Transformations written in XStream are compiled into efficient XML stream processors: the output is...
5
by: Seesharp2008 | last post by:
Hi guys! I want to do a sequence of transformations on an xml file. here is the scenario: Input.xml-------XSLT------>output.xml------XSLT------->output.xml....... for fulfiling this i have...
0
by: Hoax | last post by:
I didn't see a forum for OpenGL so i assume it would go here. I've having an issues with my camera interfering with the transformations of my geometry. Here is my Display() code, I think it's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.