Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transforming and Splitting data in a file

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28271
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 734
7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies.

I am using this approach to do my job.


Regards
Siva
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic