April 29, 2016 at 4:52 am
I was wondering whether it is possible for an XSLT file to generate multiple XML files. My process looks like the following:
1. Receive 10 XML input files.
2. Use the XML Task in SSIS to read an XML file as the input, the corresponding XSLT file as the second operand, which in turn outputs a new XML file (one that forms less outputs in the XML Source components).
3. Import the new XML file via Source XML and OLE DB Destination.
The thing is that for each of the 10 XML files I require a separate XSLT file (10 XML files = 10 corresponding XSLT files). Is it possible to accomplish this through just one XSLT file? I mean that each part of the XSLT file has a section where the desired XML file code resides. So if I'm importing File5.xml then I would simply go into section 5 of the XSLT file and it would simply generate File5-New.xml and not the other 9. I realize that this may be more of an XML/XSLT question but the XML Task is an SSIS component and I see no way to communicate through this task which section from the XSLT file I would like to execute.
I'm asking because the client would like to have one XSLT instead of maintaining 10. Yeah I know that having 10 is probably better and more "modular" but the client is always right....
May 15, 2016 at 7:55 pm
Provided that the XML files are similar you can absolutely do this. If they're not you can still do this, its just more complicated. You would have to post some sample XML and the XSLT files but this is the kind of thing I used to do all the time.
What you are talking about is a good idea too. There are many ways to accomplish this, I can't get too specific with out sample XSLT and XML but here's some general thoughts:
1. You can have an XSLT file that has a multitude of different templates and accommodates each possible scenario/XML file.
2. Create a "catch all" type of XSLT file with some if/then scenarios.
3. You can have a routine that runs before the XSLT task that creates the required XSLT dynamically. You could use SQL, some .NET language, or even an XSLT file that creates the XSLT file you need before the XSLT task runs. This way you have one routine that handles all 10 XML files.
Post some sample XML and your XSLT and I can get more specific.
-- Itzik Ben-Gan 2001
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply