IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Creating a map to unzip multiple files from a single zip file

    Posted Tue October 10, 2006 11:54 AM

    Originally posted by: SystemAdmin


    Is unzipping multiple files in WTX really as awkward as I found it to be? At the command line, the code is something like "unzip zipfile.zip" and the zipped files are unzipped. In order to do this in WTX, I first created a type tree to read a zip file. Then in the map output card, I have three functional maps. The first FM extracts the zipped file names, the second FM GETs each of the zipped files using the ZIP adapter based on the file names from Step 1. The third FM then PUTs each of the unzipped files from Step 2 using the file names from Step 1.

    Have I made this way too complicated? What have I missed?

    Jim Divoky
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 2.  Re: Creating a map to unzip multiple files from a single zip file

    Posted Tue October 10, 2006 12:07 PM

    Originally posted by: janhess


    The manual says

    Archive Restore
    Use the Archive Restore command to retrieve files from a specified archive. You
    must specify the following arguments with no preceding adapter command:
    archive_name,files_to_unzip
    Option Description
    archive_name Specify the name of the archive that contains the
    files to be restored.
    , The comma is a required separator between
    options.
    files_to_unzip Specify the files to be restored from archive.

    Data Sources
    The following is the syntax of the Archive (Zip) adapter commands used for data
    sources:
    archive_name,files_to_unzip
    Unfortunately there are no examples to show how to use it. I've only used it to create zip files.
    #DataExchange
    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender


  • 3.  Re: Creating a map to unzip multiple files from a single zip file

    Posted Tue October 10, 2006 12:21 PM

    Originally posted by: janhess


    How about using an output card to run the batch script to do the unzip?
    I tried using the adapter and it seems you need to know the name for the file you want to unzip. Your typetree for the zip file must be interesting.
    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 4.  Re: Creating a map to unzip multiple files from a single zip file

    Posted Tue October 10, 2006 12:41 PM

    Originally posted by: SystemAdmin


    Yes, your method would work. I could also model the economy of the world from a WTX map if I call the right external program. It is trivial to extract zip files in a script. My point is that I didn't find an easy way to do it from within a map. Not saying it can't be done. I just didn't find any method.

    I just wanted the file names from the zip file so the type tree is rather simple with ugly record terminators. They're actually initiators in the zipfile but I found it necessary to define them as terminators in the Type Designer.

    Here it is:

    code<?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE TTMAKER SYSTEM "ttmaker60.dtd">
    <?ANALYZE?><TTMAKER Version="6.0"><NEWTREE Filename="C:\MercatorTips\ZipMapFiles\ZipFile.mtt"><ROOT SimpleTypeName="ZipFile" SetUpProperties="DEFAULT" SetUpComponents="DELETE" OrderSubtypes="ASCENDING"><Sequence partition="NO"><Implicit/></Sequence>
    <CharTextWestern><Size Min="0" Max="S"/>
    <Western CharSet="NATIVE"/>
    <ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>
    </CharTextWestern>
    </ROOT>
    <ITEM SimpleTypeName="Blob" CategoryOrItemParent="ZipFile" partition="NO" OrderSubtypes="ASCENDING"><TypeSyntax><TERMINATOR><Literal IgnoreCase="NO"><Western CharSet="NATIVE"/>
    <LiteralValue><<50>><<4B>><<01>><<02>><<14>></LiteralValue>
    </Literal>
    </TERMINATOR>
    </TypeSyntax>
    <CharTextWestern><Size Min="0" Max="S"/>
    <Western CharSet="NATIVE"/>
    <ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>
    </CharTextWestern>
    </ITEM>
    <ITEM SimpleTypeName="BlobTrailer" CategoryOrItemParent="ZipFile" partition="NO" OrderSubtypes="ASCENDING"><CharTextWestern><Size Min="0" Max="S"/>
    <Western CharSet="NATIVE"/>
    <ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>
    </CharTextWestern>
    </ITEM>
    <GROUP SimpleTypeName="File" CategoryOrGroupParent="ZipFile" OrderSubtypes="ASCENDING"><Sequence partition="NO"><Implicit/><SequenceComponent><RelativeTypeName>Blob</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    <SequenceComponent RESTART="ON"><RelativeTypeName>FileNamePairs</RelativeTypeName>
    <Range Min="1" Max="S"/>
    </SequenceComponent>
    <SequenceComponent><RelativeTypeName>BlobTrailer</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    </Sequence>
    </GROUP>
    <ITEM SimpleTypeName="Filename" CategoryOrItemParent="ZipFile" partition="NO" OrderSubtypes="ASCENDING"><CharTextWestern><Size Min="0" Max="S"/>
    <Western CharSet="NATIVE"/>
    <ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>
    </CharTextWestern>
    </ITEM>
    <GROUP SimpleTypeName="FileNamePairs" CategoryOrGroupParent="ZipFile" OrderSubtypes="ASCENDING"><Sequence partition="YES"><Implicit/></Sequence>
    </GROUP>
    <GROUP SimpleTypeName="InitialFileNamePair" CategoryOrGroupParent="FileNamePairs ZipFile" OrderSubtypes="ASCENDING"><TypeSyntax><TERMINATOR><Literal IgnoreCase="NO"><Western CharSet="NATIVE"/>
    <LiteralValue><<50>><<4B>><<01>><<02>><<14>></LiteralValue>
    </Literal>
    </TERMINATOR>
    </TypeSyntax>
    <Sequence partition="NO"><Implicit/><SequenceComponent><RelativeTypeName>Filler_41</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    <SequenceComponent><RelativeTypeName>Filename</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    </Sequence>
    </GROUP>
    <GROUP SimpleTypeName="LastFileNamePair" CategoryOrGroupParent="FileNamePairs ZipFile" OrderSubtypes="ASCENDING"><TypeSyntax><TERMINATOR><Literal IgnoreCase="NO"><Western CharSet="NATIVE"/>
    <LiteralValue><<50>><<4B>><<05>><<06>></LiteralValue>
    </Literal>
    </TERMINATOR>
    </TypeSyntax>
    <Sequence partition="NO"><Implicit/><SequenceComponent><RelativeTypeName>Filler_41</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    <SequenceComponent><RelativeTypeName>Filename</RelativeTypeName>
    <Range Min="1" Max="1"/>
    </SequenceComponent>
    </Sequence>
    </GROUP>
    <ITEM SimpleTypeName="Filler_41" CategoryOrItemParent="ZipFile" partition="NO" OrderSubtypes="ASCENDING"><CharTextWestern><Size Min="41" Max="41"/>
    <Western CharSet="NATIVE"/>
    <ValueRestrictions IgnoreCase="NO" Rule="INCLUDE"></ValueRestrictions>
    </CharTextWestern>
    </ITEM>
    </NEWTREE>
    </TTMAKER>[/code]

    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 5.  Re: Creating a map to unzip multiple files from a single zip file

    Posted Wed October 11, 2006 02:19 AM

    Originally posted by: jvanboga


    Our unzip maps use text blobs. The problem with unzip in TX is that you need to know what files are in the zipped file. So, if you don't have a reference and have multiple files it gets difficult fast or you can use the bat file.

    Our standard is one file per archive. Archive file name contains the zipped file name.

    Has limitations as well but for internal use its easy to inforce.
    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender