DOM to String & String to DOM too Complicated

Hi Java Comunity,
I'm just wondering why one of the simplest tasks on the XML development such as creating (parsing) a DOM from a String and viceversa (Obtaining the XML as String from a DOM Document) is so Complicated.
Obviously I'm a newbie in JAXP, but not in XML, the common sense dictaminates that these tasks should be as simple as something like:
String xmlString = "<mytag>...</mytag>";
org.w3c.dom.Document xmlDoc = new org.w3c.dom.Document(xmlString);
and
String anotherXmlString = xmlDoc.getXmlString();
I already know how to perform these conversions, but I'm just wondering why you Java Developers enjoy making suffer all the programmers in the world with such complicated (and not intuitive) ways to perform simple tasks.
Comunity, what do you think???

This needs some cleanup, but it transforms an org.w3c.dom.Document object to a String.
import java.io.*;
import java.util.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
import org.w3c.dom.*;
import org.xml.sax.*;
public static String DocumentToString(Document doc)
try
ByteArrayOutputStream out;
Transformer transformer;
TransformerFactory tFactory;
tFactory = TransformerFactory.newInstance();
transformer = tFactory.newTransformer();
out = new ByteArrayOutputStream();
transformer.transform(new DOMSource(doc.getDocumentElement()), new StreamResult(out));
if (out != null)
return new String(out.toByteArray());
else
return null;
catch (TransformerException te)
te.printStackTrace();
return null;

Similar Messages

  • Covert DOM element to String

    It sounds very simple, however could not find any solution using JAXP.
    What I need is that I have a DOM element, I want to convert the DOM element into String and store into the database. I used to do it using JDOM. It has a feature something like toString.
    I know that serialization is another option, however, want to know how to do this way.

    xmlString.getBytes()No, that causes your problem. Read the documentation to see what the getBytes() method does. Here's what you should do instead:Document document = documentBuilder.parse(new InputSource(new StringReader(xmlString)));This doesn't convert from String to bytes using a bad encoding. But you also say:
    xmlString contains Japanese characters and was originally from a xml file with UTF-8 encoing.In this case there's a good chance that in reading from the file to the String you have also failed to use UTF-8 to do the decoding. Why not just pass a File object to the parser and let it deal with the encoding issues? It knows what to do.

  • Dom Document to String

    Hi!
    I am looking for a method to create a String from a Dom Document. I have been searching on the internet but all the methods I have found so far contain some deprecated classes :( . Can anyone help me please?
    Thanks in advanced

    georgemc wrote:
    When I saw [this cartoon|http://xkcd.com/763/], I instantly thought of some of the dancing about you have to do with JAXP sometimes
    :-)

  • Dom element to string

    I have a method, the argument being passed in is a dom element.
    The method will convert the element(and child node) to string. The string is then passed into a buffer writer to write to a file.
    What is the easiest/fastest way to convert the dom element to string?
    Is there a better way to write the element to a file?
    Any sample code available?

    You could try something like this:
        String elementToString(Element element)
        throws Exception
            StringWriter sw = new StringWriter();
            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            DOMSource source = new DOMSource(element);
            StreamResult result = new StreamResult(sw);
            transformer.transform(source, result);
            return sw.toString();
        }Regards

  • Method invokeMethod(java.lang.String, org.w3c.dom.Element) not found

    I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
    I will upload the 3 files that are being used for this.
    When I rebuild my files I get the following error in CustomerCO.java:
    Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
    Line 78 reads as follows:
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    Any suggestions?
    PS: I am a newbie to java and framework :-(
    Here are my files:
    CustomerCO.java:
    /*===========================================================================+
    | Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
    | All rights reserved. |
    +===========================================================================+
    | HISTORY |
    +===========================================================================*/
    package xxcu.oracle.apps.ar.customer.server.webui;
    import java.io.Serializable;
    import java.lang.Exception;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import org.w3c.dom.Element;
    import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
    * Controller for ...
    public class CustomerCO extends OAControllerImpl implements Serializable
    public static final String RCS_ID="$Header$";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    * Layout and page setup logic for a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    * 2009.07.09, Roy Feirud, lagt til for å utføre spørring
    if (pageContext.getParameter("Search") != null)
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    //Setter søkekriteriene til LindorffWS
    String Name = pageContext.getParameter("SearchName");
    String Address = pageContext.getParameter("SearchAddress");
    String Zip = pageContext.getParameter("SearchZipCode");
    String City = pageContext.getParameter("SearchCity");
    String Born = pageContext.getParameter("SearchBorn");
    String Phone = pageContext.getParameter("SearchPhoneNo");
    Serializable[] param = { Name, Address, Zip, City, Born, Phone };
    //Bygger søkestrengen
    String SearchString = (String)am.invokeMethod("initBuildString", param );
    //Initialiserer LindorffWS
    LindorffWS WsConnection = new LindorffWS();
    try
    //Kaller Web Sevice fra Lindorff
    Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    catch(Exception WsExp)
    // WsConnection = new LindorffWS();
    System.out.println("Kall til LindorffWS feilet!");
    am.invokeMethod("initQueryCustomer");
    CustomerAMImpl.java:
    package xxcu.oracle.apps.ar.customer.server;
    import java.io.Serializable;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.server.OADBTransaction;
    import oracle.apps.fnd.framework.server.OAExceptionUtils;
    import org.w3c.dom.Element;
    // --- File generated by Oracle Business Components for Java.
    public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
    * This is the default constructor (do not remove)
    public CustomerAMImpl()
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
    * Container's getter for CustomerVO1
    public CustomerVOImpl getCustomerVO1()
    return (CustomerVOImpl)findViewObject("CustomerVO1");
    * 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
    public void initQueryCustomer()
    CustomerVOImpl vo = getCustomerVO1();
    if (vo!=null)
    vo.initQuery();
    * 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
    public String initBuildString(String Name
    ,String Address
    ,String Zip
    ,String City
    ,String Born
    ,String Phone)
    String ws_string = null;
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setString(1,Name);
    cs.setString(2,Address);
    cs.setString(3,Zip);
    cs.setString(4,City);
    cs.setString(5,Born);
    cs.setString(6,Phone);
    cs.registerOutParameter(7,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    ws_string = cs.getString(7);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return ws_string;
    public String initSaveXml(Element WsXml)
    String Status = "Error";
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setObject(1,WsXml);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    Status = cs.getString(2);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return Status;
    LindorffWS.java:
    package xxcu.oracle.apps.ar.customer.ws;
    import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    //import org.apache.soap.encoding.soapenc.BeanSerializer;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    //import org.apache.soap.util.xml.QName;
    import java.util.Vector;
    import org.w3c.dom.Element;
    import java.net.URL;
    import org.apache.soap.Body;
    import org.apache.soap.Envelope;
    import org.apache.soap.messaging.Message;
    import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
    * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
    * Date Created: Fri Jul 10 10:37:21 CEST 2009
    * WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
    public class LindorffWS extends WrappedDocLiteralStub
    public LindorffWS()
    m_httpConnection = new OracleSOAPHTTPConnection();
    public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
    private OracleSOAPHTTPConnection m_httpConnection = null;
    private SOAPMappingRegistry m_smr = null;
    public Element XmlFulltextOperator(String xmlString) throws Exception
    URL endpointURL = new URL(endpoint);
    Envelope requestEnv = new Envelope();
    Body requestBody = new Body();
    Vector requestBodyEntries = new Vector();
    String wrappingName = "XmlFulltextOperator";
    String targetNamespace = "http://services.lindorffmatch.com/search";
    Vector requestData = new Vector();
    requestData.add(new Object[] {"xmlString", xmlString});
    requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
    requestBody.setBodyEntries(requestBodyEntries);
    requestEnv.setBody(requestBody);
    Message msg = new Message();
    msg.setSOAPTransport(m_httpConnection);
    msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
    Envelope responseEnv = msg.receiveEnvelope();
    Body responseBody = responseEnv.getBody();
    Vector responseData = responseBody.getBodyEntries();
    return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
    _______________________________________________________________________________________________________________________________

    Hi,
    Create an Interface to your application Module then from interface call your method,
    refer http://www.oraclearea51.com/oracle-technical-articles/oa-framework/oa-framework-beginners-guide/213-how-to-call-am-methods-from-controller-without-using-invokemethod.html for creating Interface for AM and calling it in controller.
    Regards,
    Reetesh Sharma

  • Jdev: method invokeMethod(java.lang.String, org.w3c.dom.Element) not found

    I am calling a Web Service that returns an XML-file. The XML-file should be passed to a method that puts the xml into a table in my database.
    I will upload the 3 files that are being used for this.
    When I rebuild my files I get the following error in CustomerCO.java:
    Error(78,38): method invokeMethod(java.lang.String, org.w3c.dom.Element) not found in interface oracle.apps.fnd.framework.OAApplicationModule
    Line 78 reads as follows:
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    Any suggestions?
    PS: I am a newbie to java and framework
    Here are my files:
    CustomerCO.java:
    /*===========================================================================+
    Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA
    All rights reserved.
    ===========================================================================
    HISTORY
    +===========================================================================*/
    package xxcu.oracle.apps.ar.customer.server.webui;
    import java.io.Serializable;
    import java.lang.Exception;
    import oracle.apps.fnd.common.VersionInfo;
    import oracle.apps.fnd.framework.OAApplicationModule;
    import oracle.apps.fnd.framework.webui.OAControllerImpl;
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import org.w3c.dom.Element;
    import xxcu.oracle.apps.ar.customer.ws.LindorffWS;
    * Controller for ...
    public class CustomerCO extends OAControllerImpl implements Serializable
    public static final String RCS_ID="$Header$";
    public static final boolean RCS_ID_RECORDED =
    VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
    * Layout and page setup logic for a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    * Procedure to handle form submissions for form elements in
    * a region.
    * @param pageContext the current OA page context
    * @param webBean the web bean corresponding to the region
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    * 2009.07.09, Roy Feirud, lagt til for å utføre spørring
    if (pageContext.getParameter("Search") != null)
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    //Setter søkekriteriene til LindorffWS
    String Name = pageContext.getParameter("SearchName");
    String Address = pageContext.getParameter("SearchAddress");
    String Zip = pageContext.getParameter("SearchZipCode");
    String City = pageContext.getParameter("SearchCity");
    String Born = pageContext.getParameter("SearchBorn");
    String Phone = pageContext.getParameter("SearchPhoneNo");
    Serializable[] param = { Name, Address, Zip, City, Born, Phone };
    //Bygger søkestrengen
    String SearchString = (String)am.invokeMethod("initBuildString", param );
    //Initialiserer LindorffWS
    LindorffWS WsConnection = new LindorffWS();
    try
    //Kaller Web Sevice fra Lindorff
    Element wsXml = (Element)WsConnection.XmlFulltextOperator(SearchString);
    String Status = (String)am.invokeMethod("initSaveXml", wsXml);
    catch(Exception WsExp)
    // WsConnection = new LindorffWS();
    System.out.println("Kall til LindorffWS feilet!");
    am.invokeMethod("initQueryCustomer");
    CustomerAMImpl.java:
    package xxcu.oracle.apps.ar.customer.server;
    import java.io.Serializable;
    import java.sql.CallableStatement;
    import java.sql.SQLException;
    import java.sql.Types;
    import oracle.apps.fnd.common.MessageToken;
    import oracle.apps.fnd.framework.OAException;
    import oracle.apps.fnd.framework.server.OAApplicationModuleImpl;
    import oracle.apps.fnd.framework.server.OADBTransaction;
    import oracle.apps.fnd.framework.server.OAExceptionUtils;
    import org.w3c.dom.Element;
    // --- File generated by Oracle Business Components for Java.
    public class CustomerAMImpl extends OAApplicationModuleImpl implements Serializable
    * This is the default constructor (do not remove)
    public CustomerAMImpl()
    * Sample main for debugging Business Components code using the tester.
    public static void main(String[] args)
    launchTester("xxcu.oracle.apps.ar.customer.server", "CustomerAMLocal");
    * Container's getter for CustomerVO1
    public CustomerVOImpl getCustomerVO1()
    return (CustomerVOImpl)findViewObject("CustomerVO1");
    * 2009.07.09, Roy Feirud, Lagt til for å utføre spørring.
    public void initQueryCustomer()
    CustomerVOImpl vo = getCustomerVO1();
    if (vo!=null)
    vo.initQuery();
    * 2009.08.31, Roy Feirud, Lagt til for å bygge opp input til WebService hos Lindorff.
    public String initBuildString(String Name
    ,String Address
    ,String Zip
    ,String City
    ,String Born
    ,String Phone)
    String ws_string = null;
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_WS_LINDORFF_PKG.BUILD_STRING (?,?,?,?,?,?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setString(1,Name);
    cs.setString(2,Address);
    cs.setString(3,Zip);
    cs.setString(4,City);
    cs.setString(5,Born);
    cs.setString(6,Phone);
    cs.registerOutParameter(7,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    ws_string = cs.getString(7);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_WS_LINDORFF_PKG.BUILD_STRING";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return ws_string;
    public String initSaveXml(Element WsXml)
    String Status = "Error";
    CallableStatement cs = null;
    try
    String sql= "BEGIN ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP (?,?); END;";
    OADBTransaction txn = getOADBTransaction();
    cs = txn.createCallableStatement(sql,1);
    cs.setObject(1,WsXml);
    cs.registerOutParameter(2,Types.VARCHAR);
    cs.execute();
    OAExceptionUtils.checkErrors (txn);
    Status = cs.getString(2);
    cs.close();
    catch (SQLException sqle)
    String Prosedyre = "ISS_XML2TABLE_PKG.ISS_AR_CUSTOMERS_TMP";
    String Errmsg = sqle.toString();
    MessageToken[] tokens = {new MessageToken("PROSEDYRE", Prosedyre), new MessageToken("ERRMSG", Errmsg)};
    throw new OAException("ISS", "ISS_PLSQL_ERROR",tokens,OAException.ERROR, null);
    return Status;
    LindorffWS.java:
    package xxcu.oracle.apps.ar.customer.ws;
    import oracle.soap.transport.http.OracleSOAPHTTPConnection;
    //import org.apache.soap.encoding.soapenc.BeanSerializer;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    //import org.apache.soap.util.xml.QName;
    import java.util.Vector;
    import org.w3c.dom.Element;
    import java.net.URL;
    import org.apache.soap.Body;
    import org.apache.soap.Envelope;
    import org.apache.soap.messaging.Message;
    import oracle.jdeveloper.webservices.runtime.WrappedDocLiteralStub;
    * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
    * Date Created: Fri Jul 10 10:37:21 CEST 2009
    * WSDL URL: http://services.lindorffmatch.com/Search/Search.asmx?WSDL
    public class LindorffWS extends WrappedDocLiteralStub
    public LindorffWS()
    m_httpConnection = new OracleSOAPHTTPConnection();
    public String endpoint = "http://services.lindorffmatch.com/Search/Search.asmx";
    private OracleSOAPHTTPConnection m_httpConnection = null;
    private SOAPMappingRegistry m_smr = null;
    public Element XmlFulltextOperator(String xmlString) throws Exception
    URL endpointURL = new URL(endpoint);
    Envelope requestEnv = new Envelope();
    Body requestBody = new Body();
    Vector requestBodyEntries = new Vector();
    String wrappingName = "XmlFulltextOperator";
    String targetNamespace = "http://services.lindorffmatch.com/search";
    Vector requestData = new Vector();
    requestData.add(new Object[] {"xmlString", xmlString});
    requestBodyEntries.addElement(toElement(wrappingName, targetNamespace, requestData));
    requestBody.setBodyEntries(requestBodyEntries);
    requestEnv.setBody(requestBody);
    Message msg = new Message();
    msg.setSOAPTransport(m_httpConnection);
    msg.send(endpointURL, "http://services.lindorffmatch.com/search/XmlFulltextOperator", requestEnv);
    Envelope responseEnv = msg.receiveEnvelope();
    Body responseBody = responseEnv.getBody();
    Vector responseData = responseBody.getBodyEntries();
    return (Element)fromElement((Element)responseData.elementAt(0), org.w3c.dom.Element.class);
    _______________________________________________________________________________________________________________________________

    Hi,
    wrong forum. If this is a problem related to the use of OA framework, please use the OA framework forum here on OTN
    Frank

  • Looping around an arraylist of strings to find matches(more complicated!)

    Total Posts: 1
    Help developing an algortim
    Posted: 03-05-2006 07:11 AM
    Hi,
    I have been bashing my head with this for a while, so any help is much appreciated!
    I bascially have ONE arraylist which contains filenames as strings (e.g. file.txt, file1.xml, file2.doc, file2.xml, file2.txt)
    The arraylist bascially contains a document name with there associated metadata document names. For example file1.doc (document file), file1.xml (metedata file).
    There will be siuations where for example file1.doc may not have an associated file1.xml file with it. And there may be situations where there are 2 documents and only one associated metadata file (e.g. file.doc, file1.txt, file1.xml)
    I basiclaly need to loop arond the arraylist identifying only files names that:
    - have an associated metadatafile (once identified put the document name in an arraylist of matches)
    -this arraylist cannot contain duplicate documents with an associated file name (e.g. file.doc, file1.txt, file1.xml), if this particualr situations occurs I want to put these filenames in an arraylist of errors.
    Please help! thanks in advance

    I'm a little lost as to how
    >(e.g. file.doc, file1.txt, file1.xml)
    contains duplicate documents with an associated filename. Either the .txt and .xml are both metadata files, and you are saying that there should never exist two metadata documents of the same name, or else you meant to say
    (e.g. file1.doc, file1.txt, file1.xml)in which case you meant that two data files (the .doc and the .txt) with the same name (file1) cannot exist together if there exists a metadata .xml of the same name.
    Assuming the latter is true, try something like this: (hot off the grill ;)
    import java.util.*;
    public class Blah {
       public static void main(String[] args) {
          List<String> fileNames = Arrays.asList( new String[] {
             "File1.txt", "File2.txt", "File1.xml", "File1.doc", "File1.blah", "File3.doc",
             "File4.xml", "File4.txt", "File5.doc", "File6.doc", "File6.xml", "File7.csv",
             "File7.xsl", "File7.xml", "File8.xml", "File9.doc", "File90.txt"
          String metadataExtension = "xml";
          Map<String, Set<String>> pendingFileNames = new TreeMap<String, Set<String>>();
          Set<String> metadataNamesFound = new TreeSet<String>();
          Map<String, String> verifiedMetadataFileNamePair = new TreeMap<String, String>();
          Map<String, Set<String>> verifiedBadFileNames = new TreeMap<String, Set<String>>();
          Set<String> verifiedFileNamesWithoutMetadata = new TreeSet<String>();
          Set<String> verifiedMetadataWithoutFileName = new TreeSet<String>();
          for (String fileName: fileNames) {
             String[] halves = fileName.split("\\.");
             System.out.println(halves[0]+" "+halves[1]);
             String nameOnly = halves[0];
             String extension = halves[1];
             Set<String> associatedExtensions = pendingFileNames.get(nameOnly);
             if (associatedExtensions == null) {
                associatedExtensions = new TreeSet<String>();
                pendingFileNames.put(nameOnly, associatedExtensions);
             if (extension.equals(metadataExtension)) {
                metadataNamesFound.add(nameOnly);
             } else {
                associatedExtensions.add(extension);
          for (String name: pendingFileNames.keySet()) {
               Set<String> fileExtensions = pendingFileNames.get(name);
               boolean metaNameWasFound = metadataNamesFound.contains(name);
               String fullMetaName = name+"."+metadataExtension;
               if (fileExtensions == null || fileExtensions.size() == 0) {
                 if (metaNameWasFound)
                     verifiedMetadataWithoutFileName.add( fullMetaName );
               } else if (fileExtensions.size() == 1) {
                  String fullFileName = name+"."+fileExtensions.iterator().next();
                  if (metaNameWasFound)
                     verifiedMetadataFileNamePair.put(fullFileName, fullMetaName);
                  else
                     verifiedFileNamesWithoutMetadata.add(fullFileName);
               } else {
                 if (metaNameWasFound)
                     verifiedBadFileNames.put( name, fileExtensions );
                  else {
                    for(String extName: fileExtensions) {
                        verifiedFileNamesWithoutMetadata.add(name+"."+extName);
          System.out.println();
          System.out.println();
          // System.out.println(pendingFileNames);
          System.out.println("Verified one-to-one file/metadata pairs: \n"+verifiedMetadataFileNamePair);
          System.out.println("\nVerified errors (more than one document to one metadata): \n"+verifiedBadFileNames);
          System.out.println("\nVerified metadataless files: \n"+verifiedFileNamesWithoutMetadata);
          System.out.println("\nVerified fileless metadata: \n"+verifiedMetadataWithoutFileName);
    }

  • Exception Typo: ORA-02297: cannot disable constraint (string.string)

    ORA-02297: cannot disable constraint (string.string) - dependencies exist
    Cause: an alter table disable constraint failed becuase the table has foriegn keys
    that are dpendent on this constraint.
    Action: Either disable the foreign key constraints or use disable cascade
    Note the typo of the word BECAUSE from Version 11R2 back to at least 10R2.
    Thanks.

    Actually, please also correct the words "foriegn" and "dpendent" too!

  • HT1766 I broke my screen and the phone is only a little over a month!  Is there an option that is less than getting a new phone?  We bought a replacement but it's too complicated.

    I broke the screen to my new iPhone 4s and we purchased a new screen online but it is too complicated to install.  Any solutions you can provide that won't be too expensive?

    Dirty Vegas wrote:
    Yes.
    You can get it replaced at the Apple Store Genius Bar for far less than the retail cost for replacement.
    So the user won't have to pay the retail cost for a replacement if they get it replaced?
    You mean they won't have to pay the price for a new phone to replace the broken phone with a refurbished phone thru Apple.

  • Instance String[String] problem

    HI,
    I am having problem using instance array variable in an activity, on the other hand I create instance varible of a component(bpm object) & used it in automatic activity & it works fine.
    step 1:* in albpm 6.0 studio I define instance variable name = statesList , type = String[[String]|http://forums.oracle.com/forums/] using Variable ----&gt;instance window
    STEP: 2*
    in automatic activity I tried to insert data into the instance variable as follows
    statesList \["NY"] = "New York";
    but I get the following error on above line
    {color:#ff0000}A component failed while executing activity '/TestJSPProcess#Default-1.0/Interactive{color}{color:#ff0000}' (BP-method startTest) over instance '/TestJSPProcess#Default-1.0/1/0'.
    Details:
    The method 'CIL_startTestStartTestIN' from class 'Test2.TestJSPProcess.Default_1_0.Instance' could not be successfully executed.
    Caused by: java.lang.NullPointerException
    fuego.lang.ComponentExecutionException: The method 'CIL_startTestStartTestIN' from class 'Test2.TestJSPProcess.Default_1_0.Instance' could not be successfully executed.
    at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:506)
    at fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:260)
    at fuego.fengine.FEEngineExecutionContext.invokeMethodAsCil(FEEngineExecutionContext.java:215)
    at fuego.server.execution.EngineExecutionContext.runCil(EngineExecutionContext.java:1175)
    at fuego.server.execution.TaskExecution.invoke(TaskExecution.java:428)
    at fuego.server.execution.InteractiveNormalCilExecution.invoke(InteractiveNormalCilExecution.java:430)
    at fuego.server.execution.TaskExecution.executeCIL(TaskExecution.java:553)
    at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:737)
    at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:697)
    at fuego.server.execution.TaskExecution.executeTask(TaskExecution.java:178)
    at fuego.server.execution.microactivity.InteractiveMicroActivity.executeNormalCil(InteractiveMicroActivity.java:489)
    at fuego.server.execution.microactivity.InteractiveMicroActivity.executeItem(InteractiveMicroActivity.java:442)
    at fuego.server.execution.microactivity.InteractiveMicroActivity.execute(InteractiveMicroActivity.java:100)
    at fuego.server.AbstractProcessBean$45.execute(AbstractProcessBean.java:2938)
    at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:304)
    at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
    at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:551)
    at fuego.transaction.TransactionAction.start(TransactionAction.java:212)
    at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:123)
    at fuego.server.execution.EngineExecution.executeImmediate(EngineExecution.java:66)
    at fuego.server.AbstractProcessBean.runTask(AbstractProcessBean.java:2942)
    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 fuego.lang.JavaClass.invokeMethod(JavaClass.java:1410)
    at fuego.lang.JavaObject.invoke(JavaObject.java:227)
    at fuego.component.Message.process(Message.java:587)
    at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:772)
    at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:747)
    at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:143)
    at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:135)
    at fuego.fengine.FEngineProcessBean.processBatch(FEngineProcessBean.java:248)
    at fuego.component.ExecutionThread.work(ExecutionThread.java:831)
    at fuego.component.ExecutionThread.run(ExecutionThread.java:409)
    Caused by: java.lang.NullPointerException
    at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.getData(__TestJSP2.xcdl:7)
    at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.getData_Invocator(__TestJSP2.xcdl:7)
    at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.Begin_Router(__TestJSP2.xcdl:6)
    at xobject.Fuego__AutoGen__Screenflows__.__TestJSP2.Begin_Invocator(__TestJSP2.xcdl:11)
    at Test2.TestJSPProcess.Default_1_0.Instance.CIL_startTestStartTestIN(Instance.xcdl:4)
    at Test2.TestJSPProcess.Default_1_0.Instance.CIL_startTestStartTestIN(Instance.xcdl)
    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 fuego.component.ExecutionThreadContext.invokeMethod(ExecutionThreadContext.java:499)
    ... 34 more
    {color}
    If I initialized it before using it in automatic activity as follows
    statesList as String\[String]
    statesList \["NY"] = "New York";
    no error comes... but in this way all the assignment goes into local variable & the instance variable I cerated in step 1 is still empty , I checked it on subsequent activities.
    -KASH
    Edited by: user586236 on Dec 4, 2008 8:41 AM
    Edited by: user586236 on Dec 4, 2008 8:42 AM
    Edited by: user586236 on Dec 4, 2008 8:44 AM

    I solved the problem by making the local array & insert data fetched from db into that local array then assign this array to the instance array as follows
    //local array
    statesList_local as String\[String];
    workItem.state = "NY";
    //params as String[];
    //params\[0] = "STATES"; //local var defined as String\[]
    for each row in executeQuery(DynamicSQL, sentence : "select hl7code,value from D1_STATE", implname : "newConfiguration")
         do      statesList_local[String(row\["hl7code"])] = String(row\["value"])
    logMessage String(row\["hl7code"])+":"+ String(row\["value"]) using severity = INFO
    end
    //assign local array to the instance variable one
    statesList = statesList_local;
    Edited by: user586236 on Dec 4, 2008 9:00 AM

  • Sending Map String,String data to an MXBean?

    Hi,
    I have been trying to figure out how to send a HashMap<String, String> from a JMX client to a remote MBean Server. I have looked into constructing the data using TabularDataSupport but can not figure out the exact syntax.
    I have attached the stack trace below that I'm getting. What I don't quite understand is why the mbeanserver package classes are looking for the "key" argument. Does anyone have a working example of how to send a HashMap<String, String> that they can share?
    Thanks,
    Allen
    Caused by: javax.management.openmbean.InvalidKeyException: Argument key="key" is not an existing item name for this CompositeData instance.
    at javax.management.openmbean.CompositeDataSupport.get(CompositeDataSupport.java:256)
    at com.sun.jmx.mbeanserver.OpenConverter$TabularConverter.fromNonNullOpenValue(OpenConverter.java:769)
    at com.sun.jmx.mbeanserver.OpenConverter.fromOpenValue(OpenConverter.java:110)
    at com.sun.jmx.mbeanserver.ConvertingMethod.fromOpenParameters(ConvertingMethod.java:136)
    at com.sun.jmx.mbeanserver.ConvertingMethod.invokeWithOpenReturn(ConvertingMethod.java:160)
    at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:96)
    at com.sun.jmx.mbeanserver.MXBeanIntrospector.invokeM2(MXBeanIntrospector.java:33)
    at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
    at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
    at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
    at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
    at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
    at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1426)
    at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
    at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1264)
    at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1359)
    at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
    at sun.rmi.transport.Transport$1.run(Transport.java:159)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)

    I actually found the solution by creating a new CompositeDataSupport row for each hash entry and then shoving it into a TabularDataSupport. What I don't understand is why it only works when the CompositeDataSupport row column names are the string literals "key" and "value".
    Can anyone shed some light on this?
    Thanks,
    Allen

  • Convert Map String, Object to Map String,String ?

    How can I convert a map say;
    Map<String, Object> map = new Map<Striing, Object>();
    map.put("value", "hello");
    to a Map<String,String>.
    I want to pass the map to another method which is expecting Map<String,String>.
    Thanks

    JoachimSauer wrote:
    shezam wrote:
    Because im actaully calling an external method to populate map which returns <String, Object>.Now we're getting somewhere.
    Oh wait, no, we're not! We're back to my original reply:
    What do you want and/or expect to happen if one of the values isn't actually a String object but something else?Nothing like a bit of confusion :). They are and always will be String objects.
    So this external method, call it external1 for now returns a Map<String, Object>, I then want to pass this map to another external method external2 which takes Map <String,String> as a parameter.

  • UNIX Problem with method Runtime exec(String[],String[],File)

    Hello !!
    i'm french
    scuse my english
    I got a probleme with method exec(String[],String[],File) of Runtime Class
    i don't have any probleme when my program runs on Windows NT but the same program on UNIX doesnt execute my command..
    When i use exec(String[]) methode i dont have this problem ...but i need the second one methode because i have to execute my command in a different directory than the JAVA program.
    I need that results of this command are placed in this drectory so that i can't use an exex() like that :
    exemple with a perl :
    "perl /toto/titi/hello.pl"
    I want to execute this :
    "perl hello.pl" (and hello.pl is placed in /toto/titi)
    Conclusion :
    the exec(String[],String[],File) solution is ok with NT ...
    but with UNIX ????
    Is there other solution ??
    Should i do a "cd" command before my execution ? how can i do this ??
    Thanks !!!!

    Could you post your source code (only relevant part)
    Raghu

  • Org.w3c.dom.html and org.w3c.dom.ls ?

    Please help.
    I use JAXB in VisualAge. When I imported jar files for JAXB from jwsdp-1.1. I have some errors.
    In jwsdp-1.1. I can't found classes from packages org.w3c.dom.html and org.w3c.dom.ls.
    What jar files and where I have to download?

    org.w3c.dom.DOMErrorHandler is a DOM Level 3 class.
    The Xerces2 Java Parser 2.4.0 contains an implementation of the Document Object Model Level 3.
    Get Xerces-J-src.2.4.0.zip from http://xml.apache.org/dist/xerces-j/
    DOMErrorHandler is in the xerces-2_4_0/src/dom3/org/w3c/dom/ drectory.
    Xerces-J-src.2.4.0.zip also has the org.w3c.dom.html and org.w3c.dom.ls packages.

  • SelectItems and Map String,String

    Hi all -
    I'm using Tomcat 6.0.14, JSF 1.2 and JSTL 1.2.
    Consider the following code:
    <h:selectOneListBox size="1" value="#{myBean.value}">
      <f:selectItems value="#{myBean.valueMap}"/>
    </h:selectOneListBox>And consider the following Map<String,String>, which is returned by myBean.getValueMap():
    Key: Value
    AL: Alabama
    AR: Arkansas
    The result of displaying the above map with the above code is:
    <select name="blahblah" size="1">
      <option value="Arkansas">AR</option>
      <option value="Alabama">AL</option>
    </select>Shouldn't it display like this?
    <select name="blahblah" size="1">
      <option value="AL">Alabama</option>
      <option value="AR">Arkansas</option>
    </select>if not, how do I make it display like I want it?
    Thanks
    Tim

    Kaydet81 wrote:
    Hi all -
    I'm using Tomcat 6.0.14, JSF 1.2 and JSTL 1.2.
    Consider the following code:
    <h:selectOneListBox size="1" value="#{myBean.value}">
    <f:selectItems value="#{myBean.valueMap}"/>
    </h:selectOneListBox>And consider the following Map<String,String>, which is returned by myBean.getValueMap():
    Key: Value
    AL: Alabama
    AR: Arkansas
    The result of displaying the above map with the above code is:
    <select name="blahblah" size="1">
    <option value="Arkansas">AR</option>
    <option value="Alabama">AL</option>
    </select>Shouldn't it display like this?
    <select name="blahblah" size="1">
    <option value="AL">Alabama</option>
    <option value="AR">Arkansas</option>
    </select>
    The javadoc for UISelectItems clearly states that the keys are used as the labels and the values for the, well, values.
    >
    if not, how do I make it display like I want it?Invert your map or create a method that will create the SelectItem objects from the map the way you want them.

Maybe you are looking for