Re: writing to a file in xslt
> > So is there any way to write to another file in XSLT? If I can do > that, then maybe I can compare the next value by reading that new > file.
So for example, I have a folder with 5 XML files. When I am processing the first XML file, I go read the external text file and grab the first value and assign it to this first XML file. Now, when processing the second XML file, I again go to grab the next value from the external file, but this time I have to compare this value with what was assigned to XML file number 1, and if they are the same, I have to increment this value by 1 before assigning it to the second XML file.
That's a very imperative way of describing your problem. A literal translation of that into XSLT would be to use a recursive template, processing one file at a time and passing the accumulated data on as a parameter. However if you have a more declarative description of your processing then a simpler XSLT idiom may suggest itself. For example
what you describe has a hint of grouping about it and your assignment is a group counter. If you can describe your grouping condition then you can group on that and just use position() to count groups, rather than accumulating the data by hand.
The writing of files here is a side issue, the main ideas are the same if you are generating element nodes within one file. in most cases you can use XSLT constructs such as muenchian grouping (xslt 1) or for-each-group (xslt 2) but in cases where they don't have enough flexibility you can use recursion over a sequence and have full manual control over the data processed at each iteration.
________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format