GeeCON Prague 2014*
The moose likes XML and Related Technologies and the fly likes Transforming and Splitting data in a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Transforming and Splitting data in a file" Watch "Transforming and Splitting data in a file" New topic
Author

Transforming and Splitting data in a file

shiva murugan
Greenhorn

Joined: Jan 08, 2010
Posts: 17
Hi i am into a situation where i need to transform one form of XML to another and then split the file based on threshold limit or via some grouping, mostly succeeded in the implementation but have small confusion with respect to file name.

I want the file name to be sequentially incremented, i tried all sort of option none succeeds, can someone give some heads up on it.

I am also new to XSLT, if you have better approach please feel free to tell me, My goal is to convert one form of XML to another and split the same in multiple file




Regards
Siva
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
It might be easier to develop a program using Perl or Korn Shell for this type of processing. XSLT programming can be awkward and restrictive. You basically are programming using XML elements which are translated into code by the XSLT Engine. There are limitations.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Despite its name, you can't modify the value of an <xsl:variable> once it's been created. So incrementing a variable isn't possible.

The usual way to deal with this is to use a recursive template. The number you want should be passed as a parameter; the originating template will pass 1 (or whatever your starting number is) and when the template calls itself it will pass the input parameter plus 1.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 520
    
    3
You can, apart from conceiving some recursive (named) template to achieve an apparent incremental "loop variable" which is not the easiest to construct in the sense of integrating all the functionalities related to xslt 2.0 grouping and result-document etc...

In your case I would suggest you use a technique of xsl:number for the purpose. Here is a rewritten of your posted template (I have noticed a number of omission or typos?)

Go testing it out, and you may find joyful surprise.
shiva murugan
Greenhorn

Joined: Jan 08, 2010
Posts: 17
Thanks for the replies.

I am using this approach to do my job.


Regards
Siva
 
GeeCON Prague 2014
 
subject: Transforming and Splitting data in a file