HOWTO convert org.dom4j.tree.DefaultDocument to dom4j.dom.DOMDocument

Hi All,
I have a question for spicialists in dom4j and XML.
I have a XML file. I need to read this file and get DOMDocument or DOMElement reference. How I can do this?
If I use the follow
1)
Document xDocument = (new SAXReader()).read(f).getDocument();// where f - is String file name for XML file
xDocumenrt realy have org.dom4j.tree.DefaultDocument type
How I can convert it to dom4j.dom.DOMDocument?
xDocument.getRootElement() Return reference of org.dom4j.tree.DefaultElement type
How I can covert this type to dom4j.dom.DOMElement?
2) I parse this file using standart
javax.xml.parsers.DocumentBuilder;
javax.xml.parsers.DocumentBuilderFactory;and get reference of org.w3c.dom.Document type.
After that I use org.dom4j.io.DOMReader
But method read of this class return org.dom4j.tree.DefaultDocument type.
So I have the same problem as in the first case.
Did anybody faced with this problem?
Thanks.

Please don't cross post to more than one forum. I have moved your thread from the "Java Programming" forum to this forum and will lock this thread.

Similar Messages

  • How to convert org.dom4j.Document into org.w3c.dom.Document  ?

    Hi,
    I have done googling for how to convert org.dom4j.Document into org.w3c.dom.Document , but could not get any usefull data.
    If any one is having solution or any idea, please reply.
    Thanks in advance
    <!--Session data-->

    Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

  • Casting a org.w3c.dom Node to a org.dom4j Node

    Does anybody know how I can cast (convert) a w3c.dom Node to a dom4j Node?
    If I just trying casting the w3c node "(org.dom4j.Node)" it throws an exception...

    I have a org.w3c.dom.Node after calling HttpUnit's getDOMSubtree() method.
    Now I would like to change that Node to an org.dom4j.Node so i can use dom4j's Node.valueOf() method on it.
    Any idea how?

  • Org.dom4j.DocumentException: Invalid byte 1 of 1-byte UTF-8 sequence. Neste

    Hi there,
    I'm getting following exception, when i try to parse xml containing french character like
    la valeur utilisée pour le paramètre ROWS est passée de 10000 à 5418*
    org.dom4j.DocumentException: Invalid byte 1 of 1-byte UTF-8 sequence. Nested exception: Invalid byte 1 of 1-byte UTF-8 sequence.
         at org.dom4j.io.SAXReader.read(SAXReader.java:353)
         at org.dom4j.io.SAXReader.read(SAXReader.java:264)
         at com.azure.sparkcommon.XMLHelper.loadDocument(XMLHelper.java:57)
         at com.test.Sample.main(Sample.java:41)
    Nested exception:
    java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
         at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown Source)
         at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.dom4j.io.SAXReader.read(SAXReader.java:334)
         at org.dom4j.io.SAXReader.read(SAXReader.java:264)
         at com.azure.sparkcommon.XMLHelper.loadDocument(XMLHelper.java:57)
         at com.test.Sample.main(Sample.java:41)
    Nested exception: java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence.
         at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source)
         at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source)
         at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
         at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown Source)
         at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source)
         at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.dom4j.io.SAXReader.read(SAXReader.java:334)
         at org.dom4j.io.SAXReader.read(SAXReader.java:264)
         at com.test.XMLHelper.loadDocument(XMLHelper.java:57)
         at com.test.Sample.main(Sample.java:41)
    Can any body help me out.
    Thanks,
    S

    Hey...
    I got the solution..... it's all because of charset UTF-8 used in xml doctype/CharEncoding, As my JVM is running on OS for French locale i need to make use of 'ISO-8859-1' as CharEncoding.
    This resolved my problem.
    Anyways thanks.
    Sid
    Edited by: hiremath47 on May 20, 2010 5:48 PM

  • Could not create the view: org/dom4j/io/SAXReader

    I'm using the FlashBuilder 4.1 plugin with Eclipse.  When trying to access the Data/Services tab in the Flex perspective, I get the following error...
    Could not create the view: org/dom4j/io/SAXReader
    java.lang.ClassNotFoundException: org.dom4j.io.SAXReader
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.jav a:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at fiber.core.impl.FmlModelPersistenceFactory.newModelLoader(FmlModelPersistenceFactory.java :42)
    at com.adobe.flexbuilder.dcrad.core.generation.ServicesGenerator.generate(ServicesGenerator. java:69)
    at com.adobe.flexbuilder.dcrad.core.generation.ServicesGenerationManager.loadProjectServices (ServicesGenerationManager.java:72)
    at com.adobe.flexbuilder.dcrad.core.internal.ServicesManager$ServiceExplorerPartListener.<in it>(ServicesManager.java:1235)
    at com.adobe.flexbuilder.dcrad.core.internal.ServicesManager.addListeners(ServicesManager.ja va:302)
    at com.adobe.flexbuilder.dcrad.core.internal.ServicesManager.setPage(ServicesManager.java:28 2)
    at com.adobe.flexbuilder.dcrad.views.ServiceExplorerView.createPartControl(ServiceExplorerVi ew.java:569)
    at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:375)
    at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:229)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
    at org.eclipse.ui.internal.WorkbenchPage$ActivationList.setActive(WorkbenchPage.java:4218)
    at org.eclipse.ui.internal.WorkbenchPage$18.runWithException(WorkbenchPage.java:3277)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
    at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
    at org.eclipse.ui.internal.Workbench$31.runWithException(Workbench.java:1567)
    at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2548)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLau ncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.jav a:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    ...Any ideas as to how to fix the problem?
    I'm running Windows 7 Home Premium (64 bit), Eclipise Helios Service Release 1, Flash Builder plugin 4.1 (build 277662).  On windows XP sp3, with the same version of Eclipse and Flash Builder, I do not get the error.

    I'm having this issue since ever with FB 4.7 (the normal IDE version, not the command-line one).
    The most consistent way I found to resolve it is to delete the output folders of all flex projects, then restart and perform a clean build.
    My suspect is that the incremental compilation is flawed, but cannot be sure of it.
    P.S. usually the initial error has this root exception
    Root exception:
    java.lang.NullPointerException
      at com.adobe.flexbuilder.codemodel.internal.bridge.WorkspaceSpecification.getStateLocation(W orkspaceSpecification.java:157)
      at com.adobe.flexbuilder.codemodel.internal.bridge.WorkspaceSpecification.getFileInStateLoca tion(WorkspaceSpecification.java:149)
      at com.adobe.flexbuilder.codemodel.internal.search.AbstractTextDatabase.start(AbstractTextDa tabase.java:81)
      at com.adobe.flexbuilder.codemodel.internal.search.ASSearchDataProvider.<init>(ASSearchDataP rovider.java:25)
      at com.adobe.flexbuilder.codemodel.internal.search.SearchIndexManager.initialize(SearchIndex Manager.java:155)
      at com.adobe.flexbuilder.codemodel.CMCoreActivator.activate(CMCoreActivator.java:189)
      at com.adobe.flexbuilder.codemodel.CMCoreActivator.start(CMCoreActivator.java:76)

  • Org/dom4j/DocumentException

    hi all,
    i am using hibernate and passing a XML file hibernate.cfg to session.
    i am geeting this exception there
    java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    its urgent...any ideas

    common guys...it is simple .i have got it
    just include dom jar in classpath.

  • Old netscape org unit tree doc url?

    I am looking for an old netscape article that explained how to create an org unit tree and then use the dn's of those entries in the people entries to represent their org unit., and it mentioned some code to read the relationship. Anyone have this or have the url or something comparable? It was an old tech article but things have changed so much I cant find it :)

    Hi Frank,
    I tried including -tr-inhibit:all;
    but it didn't work.
    Here's my skin registration tag in trinidaad-skins.xml
    <skin>
    <id>customSkin.desktop</id>
    <family>CustomSkin</family>
    <extends>fusion.desktop</extends>
    <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
    <style-sheet-name>org/calwin/ui/superweb/skin/css/customFusion.css</style-sheet-name>
    </skin>
    Can there be any other reason for not being applied properly.
    The images mentioned in the css are properly rendered but in the background
    default images are still coming.
    Please suggest..

  • Convertion of flat file to XML using DOM

    Hi!
    I need help for convert a flat file to XML using DOM and by taking the validation of a specified DTD. Can any body help me in this regard.
    Bye,
    lat

    first you have to decide how the flat file will map to xml. Will you use attributes or pcdata for your fields, or both? Will there be a hierarchy, or will it be mostly flat?
    Once decided, you'd probably just use a BufferedReader to read the lines one at a time, and generate Dom nodes as appropriate, and stick them in the tree.

  • How to convert a result tree fragment to NodeSet

    Dear Guru-s:
    I encountered a problem during the BPEL development, as following:
    scenario:
    Position: Transformation Activity
    Requirement: I should establish a complex data transformation, which need to assign an element of process input schema to a NodeSet's element
    My WRONG Way:_I just linked such two elements in the XSL perspective of JDeveloper 11g_......
    Problem: "javax.xml.transform.TransformerException: XML-22036: (Error) Cannot convert result tree fragment to NodeSet."(When I test the BPEL process in EM)
    How could I cover this problem?
    Thanks a lot in advance.
    BR,
    Robert

    Creating a CSV file is easier than parsing one, but I'd still go for some library code:
    http://commons.apache.org/sandbox/csv/

  • Sorry for duplicated post--How to convert a result tree fragment to NodeSet

    Dear Guru-s:
    I encountered a problem during the BPEL development, as following:
    scenario:
    Position: Transformation Activity
    Requirement: I should establish a complex data transformation, which need to assign an element of process input schema to a NodeSet's element
    My WRONG Way: I just linked such two elements in the XSL perspective of JDeveloper 11g......
    Problem: "javax.xml.transform.TransformerException: XML-22036: (Error) Cannot convert result tree fragment to NodeSet."(When I test the BPEL process in EM)
    JDeveloper Version: 11.1.1.3(11g Release 1)
    EM Console Version: 11g
    How could I cover this problem?
    Thanks a lot in advance.
    BR,
    Robert
    Edited by: Robert CAO on 2010-6-23 下午12:43
    Edited by: Robert CAO on 2010-6-23 下午12:53

    I am facing the same issue while executing a transform activity within a BPEL process.

  • Org unit tree

    hallow did some have a exemple of report like tree of org unit that when you open u see org unit and under org unit and employee regards

    U can have a look at some demo reports by SAP for tree structure development.
    SAPSIMPLE_TREE_CONTROL_DEMO
    SAPCOLUMN_TREE_CONTROL_DEMO
    SAPTLIST_TREE_CONTROL_DEMO
    Hope these reports will be helpful for U.
    Award points if helpful info.
    ~BiSu

  • [USEFUL] Howto convert .avi etc to DVD

    Hi guys,
    Dunno about anyone else, but I've been looking for ages for a way to convert various movie types into something that can be watched on a DVD player.
    I've seen a few scripts about, but nothing concrete. Just got a DVD writer yesterday, and found a very nice HowTo over at the Gentoo forums, here.
    I'm going to give it a try today - anyone know how long encoding takes? Because there's no progress bar for CLI, heh.
    Hope people find that useful, credit to the author.
    T.

    I did this one time for a 3-hour-during movie.
    I used transcode for it with meg2enc-plugin and converted the audio to ac3. You may have to upscale the movie to anamorphic 16:9 (all commercial dvd's are in this format I believe) ... What is this or do you know it already ?
    anamorphic dvd: Well the total numbers of pixels form a 4:3-image, but the movie is actually 16:9 (the image is stretched vertically). You can use yuvscaler with the bicubic algorithm for this (I believe). I gives very nice results!!! I tried some other algorithms and I have to say the bicubic algorithm is very nice. I couldn't really say the movie was upscaled.
    So you have to upscale to (for PAL) 768*576 (I think ....) (no black borders).
    How did I do this ? If you want to know this, I don't know immedialty again, but if you're really interested I can spend some time on it ...
    Anyway, I highly suggest recompiling transcode and all it's dependencies from source ... and look at the configure-options and sometime add some options .. like with ffmpeg you can see if your cpu supports the cmov-instruction and also ne sure to have -march=<your cpu-type>. Every optimization is welcome !!! For me it is athlon-tbird for athlon thunderbird. Maybe throw an O3 in it. I also have -fomit-frame-pointer. You can set these in /etc/makepkg.conf I believe (or something like that).
    Well the movie I transcode from divx or xvid to mpeg-2 (dvd) had a 3-hour duration and it took me 18 hours to transcode it ... I have to say the upscaling doubled the time ... I didn't know what I should do or knowed precisely what anamophic dvd was, so did some things twice ... I really suggest compiling things yourself with as most optimisations as possible! I first didn't optimise the scaling part and then it took 28 hours ...
    I have an athlon-thunderbird 900 Mhz 128 MB ram.
    The rest goes quicker ... You don't really haev to make menu's if you want, just specify the mpeg-2-movie-parts in dvd-author and make your dvd-directories that you can burn to dvd. You can also add multiple subtitle-translations if you want.
    It takes some while to learn ...
    If I remember well ... (I don't know if I transcoded to mpeg-2 before upscaling or not .. although upscaling first is maybe better)
    There was also an incompatibilty between transcode and yuvscalers YUV4MPEG2-format. Transcode exported the old format I think ... myabe it's solved now ... else you need to use an older mpjpegtools(for yuvscaler) I think.
    (It can also be wise to do a picture pass-through so there are as much audio-parts as picture parts ... to have less chance on desynchronisation I think ... I'm not sure about this though and about the method. You can export the audio to a separate file ... with the -m options(?) of transcode ... but not necessary maybe ... )
    Transcode the audio to ac3-format ... that -E 48000 is also important I believe (saw it on your gentoo-link). I suppose players only play some formats only ... ?
    so ... to upscale: if you splitted the audio and video already, export the video to yuv4mpeg and specify as outputfile /dev/output and pipe (|) it to yuvscaler. You can then pipe it to mpeg2enc to transclode it to mpeg-2-format. I'm not sure if I did it this way ... you can maybe also use transcode again instead of mpeg2enc. There is also ffmpeg ... but I used mpeg2enc. For mpeg-2-generation use  best-quality-output. I believe the lower the Quantisation-number the better thr quality(every part of the imahe is divied by a number I believe and the lower that number the higher the numbers stay ... lesser 0-values you'll have and so lesser is thrown away I think .... ), but maybe there is a simple option for this.
    You can multiplex the audio and video-stream to an mpeg-2stream ... with mplex or so I think.
    Then use dvd-author to create the dvd-structure, ....
    A divx can be nto so standard or so (or faulty) which can give problems ... the above passthrough for equal audio/video-parts can maybe help ... or use of mplayer pass-through wich can maybe help. It gave me some headaches ...
    Well hopes this helps a bit ...

  • Parser convert rdf to tree

    Hi everyone in the forum,
    i am not sure if this post should lay in this thread,
    I am developing an application whichas input needs to show a tree, but it should be generated from an rdf, so i am looking form a parser which trasform it rdf in a tree or data structure to let java works
    Hopefully anyone could help me cause i am lost,
    Again sorry if this subject is not in its rigth thread but i do not know where should it be paste.
    Thanks

    Check out this awesome post for more information:
    Convert the RDF to PDF in Forms

  • How to convert org hierarchy XML to CSV/Excel format using PI/XI

    Hi All,
    I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.
    Here is the example of how my input XML would look like:
    <?xml version="1.0" encoding="UTF-8"?>
    <PartyMaster type="OrgHierarchy" name="Compass Group Owned">
    <PartyMasterHierarchy>
    <Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">
    <Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >
    <Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">
    <Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >
    </Hierarchy>
    </Hierarchy>
    </Hierarchy>
    </Hierarchy>
    <Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".
    <Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">
    <Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">
    <Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>
    </Hierarchy>
    </Hierarchy>
    </Hierarchy>
    </PartyMasterHierarchy>
    </PartyMaster>
    I would like to get CSV output in the format below
    DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE
    Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value
    Levy Sector, Levy Sector, constant value, K00000, constant value
    BA Division, BA Division, A00000, AB0000, constant value
    Levy Sector Division, Levy Sector Division, K00000, K90000, constant value
    BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value
    Levy Sector Region, Levy Sector Region, K90000, K99000, constant value
    Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value
    TBA Total ,TBA Total ,K99000, K9901, constant value
    1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
    2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
    Any help will be greatly appreciated.
    Thanks.
    --Mithun

    >>> 1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?
    Use File adapter at the sender side to pick up the xml and use file adapter at the receiver side (message protocol file content conversion) to convert xml format to csv.
    Basically you have to configure in the file adapter (FCC) on the receiver side to get desired csv structure from XML.
    >>> 2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?
    Configure sender file adapter to pick up the file from the specified directory. Configure receiver file (fcc adapter) to drop the csv file after conversion.
    For sender adapter
    http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
    For receiver adapter in our case FCC (FILE content Conversion) follow the link
    http://help.sap.com/saphelp_NW04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
    Hope answered your question.
    Mapping area: simple suggestion. Keep input and output message same structure and do one to one mapping.  In the receiver fcc adapter configure for csv structure following instruction given in the above second link
    Note: FCC adapter does not support nested structure more than 2. So in your case you can achieve using conversion agent tool. Otherwise you might have to achieve through some graphical mapping.

  • HowTO: convert Image- byte[] when don't know image format?

    I have byte[] field in my DB. Images have been stored there.
    Images can be jpg/gif/png.
    My task is to scale them and save back (to another field)
    I have such code:
    I know, that getScaledInstance is bad, but please, don't pay attention. This operation +(massive image resizing will be performed once a year at night)+
    public class ImageResizer {
         private static byte[] resizeImage(byte[] sourceImg, int newWidth){
              byte[] result = null;
              Image resizedImage = null;     //output image
              ImageIcon imageIcon = new ImageIcon(sourceImg);     //source image
              Image imageSource = imageIcon.getImage();
              int imageSourceWidth = imageSource.getWidth(null);
              int imageSourceHeight = imageSource.getHeight(null);
              if(imageSourceWidth > newWidth){
                   float scaleFactor =  newWidth/imageSourceWidth;
                   int newHeight = Math.round(imageSourceHeight*scaleFactor);
                 resizedImage = imageSource.getScaledInstance(newWidth, newHeight,Image.SCALE_SMOOTH);
                 Image temp = new ImageIcon(resizedImage).getImage();// This code ensures that all the pixels in the image are loaded.
                 // Create the buffered image.
                 BufferedImage bufferedImage = new BufferedImage(temp.getWidth(null), temp.getHeight(null),BufferedImage.TYPE_INT_RGB);
                 /**And what next?*/
              }else{
                   result = sourceImg;
              return result;
         public static byte[] scaleToSmall(byte[] sourceImg){
              return resizeImage(sourceImg, 42);
         public static byte[] scaleToBig(byte[] sourceImg){
              return resizeImage(sourceImg, 150);
         public static byte[] serializeObjectToBytearray(Object o) {
             byte[] array;
             try {
               ByteArrayOutputStream baos = new ByteArrayOutputStream();
               ObjectOutputStream oos = new ObjectOutputStream(baos);
               oos.writeObject(o);
               array = baos.toByteArray();
             catch (IOException ioe) {
               ioe.printStackTrace();
               return null;
             return array;
    }On this forum I've found many solutions, but approximately all of them suppose that I know file format (PixelGrabber, ImageIO, e.t.c). But I don't know it. I know, that it can be jpeg/gif/png.
    What can I do?
    I've found that simple serialization can help me (+public static byte[] serializeObjectToBytearray(Object o)+), but seems like it doesn't work.
    Edited by: Holod on 01.11.2008 10:18

    Here I came up with one possible solution using some more functionality of ImageIO.
    public class ImageResizer {
        private static byte[] resizeImage(byte[] sourceBytes, int newWidth) throws Exception {
            byte[] scaledBytes;
            // ImageIO works with Files or Streams, so convert byte[] to stream
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(sourceBytes);
            // Why not just use ImageIO.read(inputStream)? - Because there would be
            // no way to know the original image format (I am assuming here that
            // you need to write back the image in the same format as the original)
            ImageInputStream imageInputStream = ImageIO.createImageInputStream(byteArrayInputStream);
            // assuming there is at least one ImageReader able to read the image
            ImageReader imageReader = ImageIO.getImageReaders(imageInputStream).next();
            // save image format name so we can write it back in the same format
            String formatName = imageReader.getFormatName();
            imageReader.setInput(imageInputStream);
            BufferedImage sourceImage = imageReader.read(0);
            int imageSourceWidth = sourceImage.getWidth();
            int imageSourceHeight = sourceImage.getHeight();
            if (imageSourceWidth > newWidth) {
                // be careful with integer divisions ( 500 / 1000 = 0!)
                double scaleFactor = (double) newWidth / (double) imageSourceWidth;
                int newHeight = (int) Math.round(imageSourceHeight * scaleFactor);
                System.out.println("newWidth=" + newWidth + ", newHeight=" + newHeight + ", formatName=" + formatName);
                // getScaledInstance provides the best downscaling quality but is
                // orders of magnitude slower than the alternatives
                // since you're saying performance is not issue, I leave it as is
                Image scaledImage = sourceImage.getScaledInstance(newWidth, newHeight, Image.SCALE_SMOOTH);
                // Unfortunately we need a RenderedImage to use ImageIO.write.
                // So the next lines convert whatever type of Image was returned
                // by getScaledImage into a BufferedImage.
                // Using TYPE_INT_ARGB so potential alpha channels are preserved
                BufferedImage scaledBufferedImage = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB);
                Graphics2D g2 = scaledBufferedImage.createGraphics();
                g2.drawImage(scaledImage, 0, 0, null);
                g2.dispose();
                // Now use ImageIO.write to encode the image back into a byte[],
                // using the same image format
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                ImageIO.write(scaledBufferedImage, formatName, byteArrayOutputStream);
                scaledBytes = byteArrayOutputStream.toByteArray();
            } else {
                // if not scaling happened, just return the original byte[]
                scaledBytes = sourceBytes;
            return scaledBytes;
        public static void main(String[] args) throws Exception {
            // this is just for my own local testing
            // simulate byte[] input from database
            BufferedImage image = ImageIO.read(new File("input.jpg"));
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ImageIO.write(image, "PNG", byteArrayOutputStream);
            byte[] sourceBytes = byteArrayOutputStream.toByteArray();
            byte[] scaledBytes = resizeImage(sourceBytes, 640);
            // write out again to check result
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scaledBytes);
            image = ImageIO.read(byteArrayInputStream);
            ImageIO.write(image, "PNG", new File("output.jpg"));
    }

Maybe you are looking for

  • Missing information in Actions file specification

    I wrote some code that parses the Photoshop Actions palette file. I used the Photoshop CS2 File Formats Specification PDF (dated June 2005) to understand its format. However, the following OSType keys of the "Reference Structure" type are not documen

  • IPhone 4s: upgrade from ios 5.1 to ios 6 failed and phone stuck in recovery mode

    I am on a Macbook OS 10.7.5.  iTuens 10.7. This afternoon I plugged in my iPhone 4S and started the upgrade process from iOS 5.1 to iOS 6. The update process failed at some point and now I am stuck with only the "Restore" option in iTunes. The fright

  • Time Machine backup over wifi not working after upgrade to 10.6.3

    I have a firewire external hard disk connected to directly into my imac which I use for back-up. The imac is wired into an ethernet LAN. I also backup my MacBook Pro to the same hard disk. The MacBook is connected to the backup disk via a wifi link t

  • cfoutput Results not showing up

    I have a varible set like this <cfset location = " Hello Charles"> All i want to do is show that in an input text box....but for some reason when i put my value="#location#" that is not getting it done for me i have it in an output block so that i ca

  • Domino ldap and weblogic server 6.1

    Hi, I am trying to use domino ldap for authentication in weblogic server 6.1 I configured a custom ldap realm. But the users were not listed from domino ldap and authentication also failed. Can anybody help me? Thanx in advance. - prabha.