wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Generating xsl to convert Xml into text format using transformation engine. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Generating xsl to convert Xml into text format using transformation engine." Watch "Generating xsl to convert Xml into text format using transformation engine." New topic
Author

Generating xsl to convert Xml into text format using transformation engine.

akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
hi to all !!!
I'm facing problem in generating xsl for a specific type of xml and to convert it into text file.
can anybody suggest or send me a code snippet to have this completed..
I would be very thankful for the same...
thanks
akshay
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Akshay, you'll need to be a bit more specific for anyone to be able to help you.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
Hi Lasse,
Thanks for replying
Basically my problem is , i have an xml format through which i need to generate a text file using an Xsl. I also have fixed text format now i need xsl which can convert that xml into required text format using transformation engine.
Xml Format:-
-----------
<Template description="Vehsim" name="Vehsim" id="1" >
<Variable type="Tabular" description="MX_TOTAL_TABLE" name="MX_TOTAL_TABLE" id="5" maxSeriesSize="50" >
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="Low Speed Threshhold for steering compliance to prevent numerical
instablily" source="" mappingtype="CDMField" name="*VLOW_STR_COMP(1)" semantics="SEMANTICS" id="12" maxSeriesSize="0" >
<Data id="1">987</Data>
</Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="Low Speed Threshhold for steering compliance to prevent numerical
instablily" source="" mappingtype="CDMField" name="*VLOW_STR_COMP(1)" semantics="SEMANTICS" id="12" maxSeriesSize="0" >
<Data id="1">123</Data>
</Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="lookup table characterizing Front Steer Compliance" source="" mappingtype="CDMField" name="STEER_COMP_TABLE(1)" semantics="SEMANTICS" id="10" maxSeriesSize="0" >
<Data id="1">478</Data></Variable>
</Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="Low Speed Threshhold for steering compliance to prevent numerical
instablily" source="" mappingtype="CDMField" name="*VLOW_STR_COMP(1)" semantics="SEMANTICS" id="12" maxSeriesSize="0" >
<Data id="1">987</Data></Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="lookup table characterizing Front Steer Compliance" source="" mappingtype="CDMField" name="STEER_COMP_TABLE(1)" semantics="SEMANTICS" id="10" maxSeriesSize="0" >
<Data id="1">478</Data></Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="NULL" updatecount="1" description="lookup table characterizing Rear Steer Compliance" source="" mappingtype="CDMField" name="STEER_COMP_TABLE(2)" semantics="SEMANTICS" id="11" maxSeriesSize="0" >
<Data id="1">200</Data></Variable>
<Variable type="Tabular" description="STEER_COMP_TABLE" name="STEER_COMP_TABLE" id="2" maxSeriesSize="50" >
<Variable type="Complex" comments="dfgdfgh" sourceName="Y" modifiedTime="" argumentName="NULL" updatecount="1" description="Y Coordinate of Steer Comp table" source="" mappingtype="Compliance Fit" name="Y" semantics="com.gm.transform.ComplianceSheet" id="2" maxSeriesSize="0" >
<Data id="2">54</Data>
</Variable>
<Variable type="Complex" comments="" sourceName="VALUE" modifiedTime="" argumentName="STEERCOMP_X" updatecount="0" description="Steer Comp" source="" mappingtype="Fill" name="SteerComp_X" semantics="com.gm.transform.Fill" id="4" maxSeriesSize="0" >
<Data id="2">155</Data>
</Variable>
<Variable type="Simple" comments="" sourceName="CDM" modifiedTime="" argumentName="COEFFICIENT_B" updatecount="0" description="Aligning Torque Steer Model B Coefficient" source="" mappingtype="CDMField" name="CoefficientB" semantics="SEMANTICS" id="5" maxSeriesSize="0" >
<Data id="4">144</Data>
<Data id="3">122</Data>
</Variable>
</Variable>
</Template>
Now i need to read the values(only name) inside node Variable and the Data in data node.
and display in the fashion mentioned below:
Name of the variable Value
For ex: *VLOW_STR_COMP(1) 987
SteerComp_X 155
this data is shown as an demo of text file which comes from above Xml file.
Now i need Xsl which can do this.
Thanks in advance
Waiting for your quick reply.
thanks again
akshay
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could start with this:
[ October 31, 2003: Message edited by: Lasse Koskela ]
akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
Hi Lasse,
Thanks for the solution.
It would be a great help if u provide one more solution.
I have generated required text file using your code and the code i have.
The problem now i am facing is to display result in proper format.
For ex:
Suppose the format for XML is :
<Variable type="Tabular" name="STEER_COMP_TABLE">
<Variable type="Simple" name="X">
<Data id="1">999</Data>
<Data id="2">888</Data>
<Data id="3">777</Data>
<Data id="4">666</Data>
</Variable>
<Variable type="Simple" name="Y">
<Data id="1">111</Data>
<Data id="2">222</Data>
<Data id="3">333</Data>
<Data id="4">444</Data>
</Variable>
</Variable>

Now if i have two Simple variables X & Y inside Tabular variable
whose data i have to write in text file in the fashion mentioned below:
STEER_COMP_TABLE
999 111
888 222
777 333
666 444
i.e first i have to read the name from variable type "Tabular"
and then data from variable type "Simple" one by one as mentioned above.
i need to print both X & Y variables at same level one by one.
hope i made my problem clear to u.
waiting for ur quick reply as it is really urgent.
Thanks in advance
Akshay
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
How about
akshay pandit
Ranch Hand

Joined: Jun 15, 2003
Posts: 44
Thanks Lasse for all your support.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generating xsl to convert Xml into text format using transformation engine.
 
Similar Threads
Displaying characters in multiplelines using xml and xsl
Creating XML from fixed length text file using XSL
Convert XML to XML using XSL
converting xml to xsl
CSV to XML coding in Java