Intelligently generate file structure as xml

So I have about a g'zillion songs on my personal server. (well maybe not a g'zillion, but close)
I recently wrote a simple java class to recursively run through and print the filenames under the directory name.
What i get is a nice xml document that I can render using xls. This all works very except when I hit the last folder. I can not seem to get the class to realize that it is the last folder, and insert the closing tag.
Usually I close the previous dir when i make a new one, since it was the easiest way to tell. but now I get something like this;
<Collection>
<Directory>
<Artist>Aerosmith</Artist>
<Song>Love in an Elavator</Song>
<Song>Crazy</Song>
</Directory>
<Directory>
<Artist>Afrika</Artist>
<Song>Flight of the Cosmic Hippo</Song>
missing tag
</Collection>
Since there is not another directory my app never knows to close the last. Here is the logic for improvement.
private static void compileResults() {
String lastDir="";
boolean lastSong=false;
// TODO Auto-generated method stub
for (Iterator iter = SONGS.iterator(); iter.hasNext();) {
String fileName = (String) iter.next();
System.out.println(fileName);
//get the path of current file
String tempPath=fileName.substring(0,fileName.lastIndexOf("\\"));
if(fileName.contains(".")){     
// file found - check location
if((PATH.equals(tempPath))&&(lastSong)){
// we have finished folders and are back in parent directory
closeDirectory();
System.out.println(xmlOutput.toString());
// we want to ignore files in parent folder, exit loop.
break;
// song is in child folder, append to output
appendSong(fileName.substring((fileName.lastIndexOf("\\")+1),fileName.lastIndexOf(".")));
lastSong=true;
} else {
// directory found, close previous if existed
if(lastSong) {
closeDirectory();                         
// directory listing appended to output
appendArtist(fileName);
lastSong=false;
lastDir=fileName;
}// end for
// close string buffer          
finishOutput();
Edited by: Masterkeedu on Sep 25, 2007 9:39 AM

well, if it's always the last one because of the algorithm you're doing, why not just append a </directory> tag at the end along with your collection? If it's consistently going to be the last one that isn't tagged every time (and based on looking at your code that will be the case), that would be an easier solution.

Similar Messages

  • IDOC --- XI -- HTTP (via a flat file structure, not XML)

    I am working on a senario in which we need to send a third party payroll service provider our HR Master Data records (Message type HROT_UM).  The manual method is to create a flat file from an IDOC and place the file in a shared directory, then upload the flat file by logging on to the web server.  We would like to automate this process using XI.
    Is it possible to send a flat file structure to a webserver using a HTTP receiver adapter?  If not, can you provide a basic view of how to accomplish this task.  Please note that FTP is not an option for us. 
    Any suggestions or recommendations would be greatly appreciated.

    hey
    flat file over HTTP is not possible,it takes only XML.
    have a look at the following thread
    Send file through http
    thanx
    ahmad
    PL:reward with points for helpful answers

  • In FM9, can you turn off xml parsing messages for non-structured generated files?

    Hi folks,
    In Frame9, we finally are able to gather books containing xml files and update the book's xrefs and numbering, hoorah.  This works great.
    The issue is that we have generated TOCs and Indexes that are not structured but are part of the book. We have no need to structure them, as they are used in PDFs only and are not required when we go to html.  When we update a book, we get an error logged...
    The Application configured for the XML book component is not available.
    ...for every single chapter in the book. I am assuming this is because there is no structured app that is relevant to the TOC and Index, which just appear in the structured view as "BOOK-COMPONENT".
    This error is not a show-stopper but it mucks up our processing, and we'd like to turn it off.  Does anyone know if that is possible?
    Thanks in advance for any help,
    Shelley Hoose
    Rogue Wave Software

    Hi Shelley,
    The error... "The Application configured for the XML book component is not available."
    is seen when the XML files in your books do not have an Application associated with them. You would will always see this mesaage when you update the Book if the Application is not set.
    To set Application to use for an XML file inside a book in FrameMaker9-
    Select XML File in book > Right Click-Select Properties.
    Select Application in the Use Structured Application dialog.
    Select continue to associate the XML file with an Application.
    You might find this blog post helpful if you use XML files in books- XML Authoring Projects using Hierarchical Books
    Regards,
    Nakshatra

  • XML publisher report not generating output for huge XML files

    Changed Depreciation Projections Report output type to XML.
    Defined a Data Definition and a new Data Template (RTF) for this report.
    Ran the Depreciation Projection Report to generate the XML output.
    Ran the XML Report Publisher report to generate teh PDF/Excel output of the above report.
    Output generated for smaller XML files. When XML size is big, the program is running for hours without generating the output.
    Teh RTF template is basically a matrix report in which the number of columns in the report is based on the number of periods the report is run for.
    The same is not working in the Desktop version also. The system is hanging when i try to view the preview pdf.
    The XML file size is approximately 33 MB.
    Please let me know if there is any way we can increase the memory size to see the output.
    Thanks,
    Ram.

    for publisher use Category: E-Business Suite

  • Export/Import Process in the UI for Variations Content Translation is Generating CMP Files with No XML

    We have a SharePoint 2010 Publishing Website that uses variations to deliver contain to multiple languages. We are using a third-party translation company to translate publishing pages. The pages are
    exported using the  export/import using the UI process described here: "http://blogs.technet.com/b/stefan_gossner/archive/2011/12/02/sharepoint-variations-the-complete-guide-part-16-translation-support.aspx".
    Certain sub-sites are extremely content-intensive. They may contain many items in the Pages library as well as lists and other sub-sites. 
    For some sub-sites (not all), the exported CMP file contains no XML files. There should be a Manifest.XML, Requirements.XML, ExportSettings.XML, etc., but there are none. After renaming the CMP file
    to CAB and extracting it, the only files it contains are DAT files.
    The only difference I can see between the sub-sites that generate CMP files with no XML files is size. For example, there is one site that is 114 MB that produces a CMP file with no XML files. Small
    sites do not have this problem. If size is the problem, then I would think the process would generate an error instead of creating a single CMP file that contains only DAT files. However, I do not know exactly what the Export/Import Process in the UI is doing.
    This leads to two questions:
    1.
    Does anyone know why some CMP files, when renamed to *.CAB and extracted, would not contain the necessary XML files?
    2. Second, if exporting using the UI will not work, can I use PowerShell? I have tried the Export-SPWeb, but the Manifest.XML does not contain translatable
    content. I have not found any parameters that I can use with Export-SPWeb to cause the exported CMP to be in the same format as the one produced by the Export/Import process in the UI.
    As a next step, we could try developing custom code using the Publishing Service, but before doing this, I would like to understand why the Export/Import process in the UI generates a CMP that
    contains no XML files.
    If no one can answer this question, I would appreciate just some general help on understanding exactly what is happening with the Export/Import Process -- that is, the one that runs when you select
    the export or import option in the Site Manager drop down. Understanding what it is actually doing will help us troubleshoot why there are no XML files in certain export CMPs and assist with determining an alternate approach.
    Thanks in advance
    Kim Ryan, SharePoint Consultant kim.ryan@[no spam]pa-tech.com

    I wanted to bump this post to see about getting some more responses to your problem. I'm running into the same problem as well. We're running a SharePoint 2010 site and are looking at adding variations now. The two subsites with the most content take a
    while to generate the .cmp file (one to two minutes of the browser loading bar spinning waiting on the file). Both files are generated with a lot of .dat files but no .xml files. I was thinking like you that it must be a size issue. Not sure though. Did you
    ever happen to find a solution to this problem?

  • CA - Error when trying to generate an amended RL1 XML file

    Dear Community,
    In case you try to generate an amended RL1 XML file and you get the error "Element content is invalid according to the DTD/Schema", it means the system incorrectly missed the tag corresponding to Box O. If you are facing this issue please access the wiki page below, which points to a FAQ in PY-CA, where you will be able to find how to solve it.
    http://wiki.sdn.sap.com/wiki/display/ERPHCM/FAQinPY-CA
    BTW, we created the question/answer from a suggestion of a customer who faced this issue before and believes through this way more people can find help and solve their issues quickly. Suggestions like this are more than welcome. Thanks for that!
    Kind regards.
    Felipe Grandi

    Hello All
    Those who are facing the DE9 SUI XML download issue for CA. I  created the very high priority OSS note to SAP, I explained issue to them. Please find their email below:
    They are going to come up with the fix on 04/25/2011
    Hi Murugappan,
    Thanks for raising the issue.
    As spoke on the phone, I'm fowarding your message to development. They
    will keep the analysis on monday and contact you with their results.
    Best regards,
    Gabriel Marx Bellina
    Support Engineer MS
    SAP Active Global Support- HCM

  • Flat File to simple XML structure in Mail Sender Adapter

    Hi,
    I have a scenario, where I want to put the content of a flat file (text, no csv or similar), which is an attachement of an e-mail, into a simple XML structure: entire file content as content of one XML tag. E.g.:
    file content:
    "abcdefgh"
    xml file:
    <root>
      <content>abcdefgh</content>
    </root>
    Do I need to use MessageTransformBean? Or is there an easiert way?
    Thanks,
    Torsten

    Hi Dirk,
    When we use MessageTransform, we can use ContentDisposition to specify, as to whether the payload has to go as an attachment or inline(as the mail itself.)
    It could also be a text file. Right?
    Just take a look at this..
    http://help.sap.com/saphelp_nw2004s/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
    cheers,
    Prashanth

  • Is there any way to generate pdf from an xml file using single java class

    i m working on generating a pdf file from an xml file. i want to use only a single java class to do so. if theres any such code available please help me to find out.
    Thanks
    Gurpreet Singh

    exactly,
    here are some libraries which are open sources;
    http://java-source.net/open-source/pdf-libraries hope it's useful. :D

  • Receiver File channel for XML files: with carriage return

    Hi all,
    we are using a receiver FILE channel to generate an XML file that is sent to an external partner.
    The XML file looks good in a parser (IExplorer). But in fact there are not carriage return / line feeds between the XML tags
    of the XML payload in the file.
    Our partner now requires the XML file in a more vertical structure which means: for every tag a separate line (like it is displayed in a parser)
    Does anybody know a more general way to convert to a vertical XML structure (so with carriage return line feed).
    There is one entry in the SDN dealing with this topic but suggesting using an UDF. I think this is a very specific way.
    I don't think it is a good way to change/enhance the message mapping just because of a general formating change.
    Is it better to use an XSLT mapping as a second step in the interface mapping or a JAVA adapter module to convert ?
    any experiences? suggestions? examples?
    Thank you very much
    best regards
    Hans
    examples:
    original by XI receiver FILE adapter
    <?xml version="1.0" encoding="UTF-8"?>
    <MT_batchStatus><type>BS</type><header><message><messageSender>SENDER</messageSender><messageDate>20090723143720</messageDate> ... and so on
    required:
    <?xml version="1.0" encoding="UTF-8"?>
    <MT_batchStatus>
    <type>BS</type>
    <header>
    <message>
    <messageSender>SENDER</messageSender>
    <messageDate>20090723143720</messageDate>
    ... and so on

    >
    Hans Georg Walter wrote:
    > Is it better to use an XSLT mapping as a second step in the interface mapping or a JAVA adapter module to convert ?
    > any experiences? suggestions? examples?
    In such a case, the best is to write an generic XSLT or Java mapping that will attempt to do the pretty printing/formatting of the xml.
    The advantage of a generic one is that you can reuse the same class/jar for many other scenarios.
    so the flow will be as below in your interface mapping;
    1. your specific source to target mapping
    2. the generic formatting class

  • I generate file (PDF, HTML, etc) the report is empty but I run in paper

    Hi
    I use oracle Report10g
    When I generate file (PDF, HTML, etc) the report is empty but I run in paper design show data, the report in the paper design show many pages, when generate file show only the information of the margin in the main seccion and the body is empty,
    Thanks

    Thanks Daniel for pointing that out.  Though you answer is helpful but I am not sure if that is what I would want to do.
    The link you provide for csv says "For each report there's an _report.xdo file that contains the XML structure of the report... "   It suggests I modify the .xdo file for each report.  I currently have 16 reports.
    Does it mean I modify the .xdo file for all 16  and what happens if someone creates a 17th report ?
    Also, what if I run the same report using different input parameters will that change the xml structure for the report  and therefore will need me to modify the .xdo again ? (I think it should not change the xml structure so the answer should be "NO" to that, unless I change the structure of the report).
    Finally, the link you provide says after doing what it suggest  "Now log back into BI publisher and select the report. You should now be able to see that CSV is now an option."
    CSV should be an option where ? on what screen/page ?  Maybe PDF is already an option for me that I cant see because I do not know where that option is.
    I was hoping there would be something I could do on the xdo_metadata sheet (in the data constraints section or elsewhere) OR in BI Publisher itself as some property of the report.
    I will try out what you suggest any ways.
    M. Jamal

  • Sending Email after generating Files

    Hi Experts,
    My requirement is very specific , I am using PI 7.0 and  the scenario is outbound proxy to file.
    I am required to generate some files from the  incoming XML structure and place them on a destination folder.
    But it is also required that there must be an email sent to a set of id's as soon as the files are created , I have three questions :
    a) What is the mechanism by which SAP XI can get an acknowledgement back from the folder after the file creation to send an email ?? Is it possible to receive an acknowldgement in this scenario and send email via mail adapter
    b) Should SAP XI send an acknowledgement back to SAP after generating files or after the File receiver Adapter bean is excuted for SAP to send the email ?
    c) Do i have to use BPM essentialy for this ? and if yes .. can you please forward some links specific to this scenario , i have never done BPM
    thanks
    Dev

    Hi Praveen
    Thanks for your reply
    I request you to please help me with  some links on BPM as you said send step and requesting acknowledgement ,  since I am new to BPM ,,,
    how difficult is that , to accomplish ?
    Is there a blog or an article which displays a step by step for this or something similar to this ?
    it  will be really helpful
    thanks
    Dev

  • File Structure with iTunes on an External Drive

    This is an image of the file structure on my external drive that holds all of my iTunes music:
    Is this correct, or should I have set it up differently? I am asking since it is differnet the the iTunes file structure on my MacBook Pro and some files will get uploaded to my external drive and others will go onto my MBP,s iTunes Music folder. All of my iPhone/iPad apps, Album Artwork, Mobile Applications. I have Book folders on both drives and the both have books on them.
    I should say that I had a major problem a few years ago, which has nothing to do with the above problem, with one of the iTunes updates which disconnected most of my songs from their respective files. I tried a solution a friend sugested, which really messed up the files and now many of the files have different info inside the song files, i.e., Otis Redding as the Artist on a Radiohead track. Or another groups cover for a Beatles album. I have a large library and have gone through slowly and fixed many things, but it is still quite messy and a huge bummer.. As a proud new owner of a Late 2011 MacBook Pro, I would love to be able to have a solution for this as well.
    TIA

    Well I just went through the same thing. I had a Lacie Porsche mobile drive at 80GB and changed to a Lacie Rugged 250. I keep all my music on external never local. Not a fan of loading my laptop. Anyways.... I was getting those same errors. I had copied all the itunes library contents from the Porsche drive to the Rugged drive. It took quite some time to transfer so you knew it was working. Then changed in the preferences of iTunes to save in the Rugged drive. If you trashed or deleted any files from the new drive and just put them in the trash without emptying you get that 501 trashes path. I found I had multiple duplicates of songs with the name of the song followed by a 1.mp4a. I think the library.xml file is the key to a clean transfer of music. I think this file is stored locally in your user folder and then it's used to direct to the alternate drive but from what I've read it's the file with all the playlist information and stuff on it. If you find it and move it over to the mobile drive then hold option and boot up itunes then tell it to look for that file on the new mobile I think you'll have no worries. I'm actually gonna try this myself.
    You don't want to know how it got it working. I physically opened every music file on the rugged drive to make sure the were all where they were supposed to be. All 70'gb's of music. Never doing that again.

  • File Structure - Sender Communication Channel

    Hi All,
    My Sender flat file structure is below like this
    Filed1|Field2|Field3|Field4|Field5|Field6
    Filed1|Field2|Field3|Field4|Field5|Field6
    Filed1|Field2|Field3|Field4|Field5|Field6
    Filed1|Field2|Field3|Field4|Field5|Field6
    Filed1|Field2|Field3|Field4|Field5|Field6
    Filed1|Field2|Field3|Field4|Field5|Field6
    I did the Sender Communication Channel configuration  - Content Conversion
    Document Name : XXX
    Document NameSpace: XXXX
    Recordset Structure: MT_Test,*
    Recordset Sequence: Ascending
    Key field Type: String Case-Sensitvie
    MT_Test.fieldNames: Filed1,Field2,Field3,Field4,Field5,Field6
    MT_Test.fieldSeparator: '|'
    MT_Test.additionalLastFileds: ignore
    MT_Test.endSeparator : 'nl'
    ignoreRecordsetName: true.
    But its pick the file, In SXMB_Moni show Currect...
    But in Runtime workbench, in Communication Channel moni, it show below like this,
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_Test xmlns:ns0="http://XXXXX">
    <JOBS />
    </ns0:MT_Test>
    What is the Issue, where i missed some thing, In message mapping, its correct..
    Thanks.
    SR

    SR,
    I am still little confused with your below statement.
    But its pick the file, In SXMB_Moni show Currect...
    But in Runtime workbench, in Communication Channel moni, it show below like this,
    >
    > <?xml version="1.0" encoding="UTF-8" ?>
    > - <ns0:MT_Test xmlns:ns0="http://XXXXX">
    > <JOBS />
    > </ns0:MT_Test>
    You mean to say that in MONI, the mapping output is fine, but when you check the output at RWB -> CC Monitoring for the Sender Channel, then you get the above mentioned XML?
    This means that there is nothing wrong with your source CC settings. If the entry in RWB -> Sender CC is wrong, your MONI entry will never be right. So, this is really weird.
    What is the source structure that you have defined in DT?
    Regards,
    Neetesh
    Edited by: Neetesh Raj on Sep 29, 2009 2:31 PM

  • Iphoto file structure

    I hate the date file structure for iphoto. If I move to a programme which isn't iphoto, I cannot navigate through the date structure to find certain photos.
    Why is it when I name a photo in iphoto, the name does not show in the file structure. Is there any way around this or am I stuck with using iphoto for ever. Could be a probleem if Apple went bust
    TIA Anteric

    Hi anthony,
    The iPhoto 6 files organization is now by Years/rolls
    iPhoto 6 Library folder in the Finder
    As you can see the structure is now related to rolls. Rolls are created for each folder you import and each import session from a camera.
    It is very easy to change the names of film rolls within iPhoto to make them easier to find images within. Open the info panel in iPhoto by clicking on the "i" icon. Once it is opened, click on the roll title in the viewing window.
    Click on the word "title" in the info pane and type in your new title. I like to use a date and text format such as 12/25/05 Christmas at Mom's, 1/05/06 my birthday, etc. Once the roll names are changed within iPhoto, they are also changed within the Finder, making it easy to locate an image.
    When importing from a camera, make sure you name the roll with a date and text before the import.
    The title you give a photo in iPhoto stays within iPhoto. the image file name remains the same in the Finder.
    If you want to rename images, it should be done before importing into iPhoto.
    download using your camera software or Image Capture, rename the photos, then import into iPhoto.
    If you need to access photos from an album it is very difficult for a third party application to navigate the iPhoto Library in order to find the photo you need. You will have to know the date of import(iPhoto 5), or roll name (iPhoto 6) in order to find the photo.
    There are some third party applications that can read the xml file and can navigate the iPhoto library and show you the Albums. Hopefully more applications will be revised to read this file.
    Until then you will have to Share/Export the photos to the desktop. You can then navigate to the desktop to use the photos (example: web uploading from online photo site)
    If your application supports drag and drop, you can drag the photo from an open iPhoto Library window into your application.
    For email you can also use the email icon within iPhoto to open a message with the highlighted photo attached.
    You can also use spotlight to find images in an Album...
    This is what I have done using Spotlight to find my images that are in iPhoto albums without opening iPhoto..
    In iPhoto, select the album, then select all, go to Photos/batch change.
    Change the comments to text. In the text field I put the name of the Album.
    Do this for each album.
    Close iPhoto.
    Open Spotlight and put in the name of the Album ( you have to remember the names of the albums or have then written down)
    In the spotlight search results. click on "show all"
    Under "Images" click on the "xx more" to show all the images in the album.
    Make sure you have it in icon view, the icon view box is the last one on the blue images line.
    Now you can control click on the image to "reveal in finder", open in iPhoto or Mail, etc.
    I am not sure if this is going to make you happy and it is a little more work, but you can find images in albums and even view them in a slideshow (by clicking the play arrow at the end of the Images highlighted blue line) using Spotlight, all without opening iPhoto.
    One important thing to know is you can set up a graphic program to be an external editor (when you double click an image in the library} such as PhotoShop or PS Elements. You set up that within iPhoto Preferences. Just make sure you save the image flattened and with the same name. The edits will then be relected in iPhoto when you hit "save".
    I have just found this useful piece of info at Macoshints.com
    "Since Apple developed its "digital hub", with iLife and now iWork, I have wanted to have a system-wide panel that would let me choose pictures from my iPhoto library without having to open the application.
    For example, if I want to add a picture to a TextEdit RTFD document, I had to launch iPhoto, chose the picture, and drag it to the document. Waiting for iPhoto to launch can be long if you have a lot of photos.
    But there is a way to get around this, using an Automator action.
    1. Open Automator, and click iPhoto.
    2. From the list of actions, select Ask for Photos, and drag it to the right-hand pane.
    3. Save this as a plug-in, and select Script Menu (the script menu that displays in the menu bar) so it is accessible anywhere. (If this menu is not visible, launch the AppleScript Utility in /Applications/Applescript, and check 'Show Script Menu in menu bar.')
    Next time you need a picture from your iPhoto library, select this action from the AppleScript menu, and you'll have a media browser that lets you do so without opening iPhoto. "
    Two Apple kbs for you to read
    Don't tamper with files in the iPhoto library folder
    About the iPhoto Library folder

  • Generate file on F110

    Dear Friends,
                        Please help how to generate file from the
    F110 Automatic Program and f-58 Vendor Payment
    we had a requirment to generate file on documents posted on the these transactions generate file and send it to other addon system I will assign full points for your suggession.
    Regards
    Bharath

    HI,
    When configuring the payment methods for the country (transaction OBVCU), choose the payment medium program as RFFOM100. 
    From se38, pls read the documentation for the program, which will give you the various options & the required config too. 
    You would also need to configure the instructions keys as required. 
    To generate the DME file, you have to run the automatic payment program with this payment method. 
    After the payments have been successfully posted, you can go to DME administration and with the help of dme manager download files on your PC. 
    SAP has determined that the standard print programs for automatic payments will no longer be supported, and will be replaced by transfer structures created by a tool called the DME Engine. 
    This tool enables the business to create DME output files without ABAP development, and can be attached to a print program and form for the creation of Payment Advices. 
    Outside of the DME Engine (DMEE), the majority of the configuration takes place within the following IMG menu path: 
    IMG Path: Financial Accounting -> Accounts Receivable and Accounts Payable -> Business Transactions -> Outgoing Payments -> Automatic Outgoing Payments -> Payment Media -> Make Settings for Payment Media Formats from Payment Medium Workbench 
    Config 
    Assign Selection Variants 
    IMG -> Financial Accounting -> Accounts Receivable and Accounts Payable -> Business Transactions -> Outgoing Payments -> Automatic Outgoing Payments -> Payment Media -> Make Settings for Payment Medium Formats from Payment Medium Workbench -> Create / Assign Selection Variants or transaction 
    OBPM4..select your format that you are using 
    Check in FBZP config that all is linked! 
    Although this is bitty but you need to work through it! 
    Start with FBZP, create all there than go to DMEE either to create your own format or use the standard ones.. than go to the menu path above and work through from create to assign... 
    hope this is clear
    assign points.
    with regards
    krishna

Maybe you are looking for