Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transforming and Splitting data in a file

 
shiva murugan
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.

I am using this approach to do my job.


Regards
Siva
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic