How to add DTD syntax line into XML using java code

Hi,
I am building xml file with java, usiing document.createElement()
and document.appendChild(element),
like that
now i need to add dtd file path and synatx in the top of the xml file,
how can i do it through java code
any body could help me
i appreciate your help.
thanks
Durga

Hi Suneetha,
Thanks for your reply..
Now i am getting docType in xml file but not in the format of what i want
please look at my code
i need
<!DOCTYPE myRootElement SYSTEM "myXMLDTD.dtd" >
but i am getting
<!DOCTYPE myRootElement PUBLIC "" "myXMLDTD.dtd">
There is change i need to get the SYSTEM in place of PUBLIC and i need to get rid of "" code between dtd and PUBLIC
for this i am doing in my code as
DocumentType theDocType = new DocumentImpl().createDocumentType ("SYSTEM","","myXMLDTD.dtd");
Document theDoc = new DocumentImpl(theDocType);
i dn't know what is the wrong ? i dn't know what are the parameters at what place to pass if you know any thing just let me know
thanks in advance
and i apperciate you help.
Durga

Similar Messages

  • How to Append two  word documents into single  using   java

    How to Append two word documents into single using java
    we tried this but it's not append the one word document to other
    source code:public class AppendTwoWordFiles {
         public static void main(String []arg)throws IOException
              FileInputStream fi=null;
              FileOutputStream fo=null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                   File f1=new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2=new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2,true);
                   byte b[]=new byte[2];
                   while((fi.read(b))!=-1);
              fo.write(b);
    System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              finally{
              fi.close();
              fo.close();
    plz reply me quickly ,,,what can i follow

    Use this code ..
    and give the path of the both file like this.....
    source file ---- C:/workspace/Practice/src/com/moksha/ws/test/practice.text
    destination file ---- C:/workspace/City/src/com/moksha/ws/test/practice1.text
    import java.io.*;
    public class AppendTwoWordFiles {
         public static void main(String[] arg) throws IOException {
              FileInputStream fi = null;
              FileOutputStream fo = null;
              try {
                   System.out.println("Enter the source file name u want to append");
                   BufferedReader br = new BufferedReader(new InputStreamReader(
                             System.in));
                   File f1 = new File(br.readLine().toString());
                   System.out.println("Enter the Destination file name ");
                   File f2 = new File(br.readLine().toString());
                   fi = new FileInputStream(f1);
                   fo = new FileOutputStream(f2, true);
                   byte b[] = new byte[2];
                   int len = 0;
                   while ((len = fi.read(b)) > 0) {
                        fo.write(b, 0, len);
                   System.out.println("Successfully append the file");
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException e) {
                   e.printStackTrace();
              } finally {
                   fi.close();
                   fo.close();
    }

  • How can we get requester's user id using java code

    Hi,
    How can we get requester's user id using java code?
    eg: If i had logged in as xelsysadm and request a resource for user uid101 on the userid field it should display uid101 and not xelsysadm.
    also,
    I have a resoure "A" which on revoking should also revoke resources B and C. How can it be done. Resource A, B, and C are 3 different resource objects.
    ==Thanks,
    doki

    Ok, so there is a way, but it's not available during submission. You can use the findRequests api. From the result set, get the "Requests.Consolidated Data Value" value. In this information, you will get an xml formatted data. It provides the list of users on the request on the left side after submission. After the request is completed, this value is available. Upon completion, you could get the request information, get this value, and parse the information for user ids.
    In the same adapter, use the following API:
    formIntf.setObjectFormData(objInstanceKey, formHash)
    The formHash is a hashtable containing the field name on your object form, and the values you wish to populate it with. You could create a textarea box on your object form and populate the userids for who the request is for.
    However, this makes absolutely 0 sense. When you get a request, the list of userids are listed right there on the request.
    -Kevin

  • How to send sms to mobile from tomcatserver using java code?

    Hi,
    Could you please let me know that,
    How to send sms to mobile from tomcatserver using java code? Please provide the code snippet.
    Thanks in advance.

    Yes, but something needs to send that message. You can't just take an arbitrary computer and send an SMS, it does not have the hardware to do that.
    So either you have a mobile through which you do that or more likely - you use some sort of online service to do it. Whatever choice you make will determine what code you will have to write to get it done. Nobody is going to deliver the code to you, that's your job. It is also your job to figure out what service you are going to use.

  • How to dynamically configure JPA setting at runtime using java code?

    Hi,
    I am new to EJB 3.0 and JPA. I am trying to help my company to deploy the use of JPA in EJB3.0. Currently, i am trying out with OpenJPA in IBM Webshpere Application Server 7.0. We have four different WAS servers running for testing, system integration testing, user testing and production respectively, and in each region, the configurations for data source, JDBC username and password, schema, etc are different. So i think i would need to configure the JPA setting during runtime using Java code that determines which is the environment. And apparently i am stuck with the limited knowledge i have.
    1) I understand that i could override the JDBC in the persistence xml by creating entity manager using entity manager factory. But is it possible that i do similar thing by using inejction of persistence context on entity manager to obtain a container managed entity manager?
    2) Alternatively, it is possible to create multiple persistence unit in the XML and inject different PU to the entity manager, am i right? But how to inject dynamically since @PersistenceContext(unitName="xxx") only accepts constant declaration.
    3) Is it possible that the JDBC username and password are read from properties file?
    Thanks for your help in advance!

    Hi
    Thanks for the reply.
    Are you saying that i have to configure the data source authentication to the backend DB2 using the JAAS-J2C? Correct me if i am mistaken. I guess i am unable to do so as the application server setup only contains one data source, and the server hosted a number of applications. Every applications has their own JDBC username and password supply to the data source (the ID supplied at the DB2 side will decide which resource can access) and thus, i have to supply the username and password at runtime. Talked to the server guy and seems that it is not feasible to have seperate datasource for each applications as considered to the volume of applications hosted inside the server.
    Any suggestion?

  • How to launch Jar file in Mac Os using java code??

    can anyone tell me how can i launch another jar file in my apllication using java code.

    define "launch".
    - You want to run a new java program in a separate process? (see Runtime.exec())
    - You want to run a method in a specific class in the jar? (add jar to application classpath and then simply instantiate the class and call the method)

  • How to create a table in the file using java code.?

    HI,
    I should export the data from the view objects to a word document. I have done that but I should
    display the data in the form of a table.
    Kindly come up with the necessary information on how to create a table in the file using java.
    Thanks,
    Phani

    Hi, Thank you for responding to my query.
    The below are the details of my code.
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding StudentDetailsContent =
    (DCIteratorBinding)dcBindings.get("StudentView1Iterator");
    OutputStreamWriter w = new OutputStreamWriter(outputStream, "UTF-8");
    Row currentRow =
    StudentDetailsContent.getRowSetIterator().first();
    Object a[]= currentRow.getAttributeValues();
    int i;
    for(i=0 ;i<=a.length;i++){
    w.write(a.toString());
    w.write(" ");
    w.flush();
    I am usning this coding to achieve the task of exporting data to file.
    I need to display this information in the table that is where I need help from you people.
    Thanks,

  • How to store the data read from excel using java code in Ms access database

    Hi. I wrote a code to read the data from excel. May i know how can i save it to Ms access database using java. Also i have many excels. So i should not connect the database using DSN. So is there any other way to achieve this?

    kramish wrote:
    Im pretty sure that Access does support JDBCNo it does not. It supports ODBC.
    just doing a quick Google came up with some pages:
    http://blog.taragana.com/index.php/archive/access-microsoft-access-database-from-java-using-jdbc-odbc-bridge-sample-code/
    http://www.javaworld.com/javaworld/javaqa/2000-09/03-qa-0922-access.html
    Both articles explains how to use the jdbc-odbc bridge. I think I've seen a pure jdbc driver for access but it wasn't from Microsoft and it wasn't free.
    Kaj

  • How to add script editor webpart into xml format

    Hi,
    I need to add the script editor webpart on to my sharepoint page using this format :
    <AllUsersWebPart WebPartZoneID="WebPartZone6" WebPartOrder="1">
            <![CDATA[
          <webParts>
           <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
            <metaData>
               <type name="Microsoft.SharePoint.WebPartPages.ScriptEditorWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
               <importErrorMessage>$Resources:core,ImportErrorMessage;</importErrorMessage>
            </metaData>
            <data>
             <properties>
              <property name="Title" type="string">$Resources:core,ScriptEditorWebPartTitle;</property>
              <property name="Description" type="string">$Resources:core,ScriptEditorWebPartDescription;</property>
              <property name="ChromeType" type="chrometype">None</property>
                  <property name="Content" type="string">
                       &lt;style type=&quot;text/css&quot;&gt;.header {;top: 100px;left: 10px;width: 100%;color:#ff8800!important;}.headerpara {;top: 140px;left:
    10px;width: 90%;color:white;}.image {;width: 100%;}.heading {;bottom: 10px;left: 20px;width: 85%;color: white!important;}&lt;/style&gt;
                  </property>
             </properties>
            </data>
           </webPart>
          </webParts>
            ]]>
    the webpart is successfully added to the page but when it renders it's css is not got applied on to the page instead the css gets render as a text which is :
    <style type="text/css">.header {;top: 100px;left: 10px;width: 100%;color:#ff8800!important;}.headerpara {;top: 140px;left: 10px;width: 90%;color:white;}.image {;width: 100%;}.heading {;bottom: 10px;left: 20px;width: 85%;color: white!important;}</style>
    i follwed the follwing link as an example :http://sharepointsnacks.blogspot.in/2014/02/sharepoint-2013-script-editor-web-part.html
    i am not sure is there anything which i am doing wrong but struggling a lot with this .
    Any help appreciated .
    Thanks

    Hi Avnish Gupta,
    Continue to Lakshmanan, you may need to add your CSS Styles in a <ContentLink> tag like below:
    <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
    </Content>
    More information:
    Adding content editor web part with default content through Visual Studio:
    http://spointdebo.blogspot.jp/2013/12/adding-content-editor-web-part-with.html
    Best regards
    Zhengyu Guo
    TechNet Community Support

  • How to add data in datatable by popup using java script?

    Hi
    I have a datatable in my jsp page. Onclick of button i am opening a popup window. On the popup window I am haveing list of data. I want to select data by checking the checkbox and the selected data need to be populated on the datatable. I am not getting any clue to proceed.
    Can anyone suggest me any solution for this. Its very urgent.
    Regards
    Rishab.

    The following article might provide new insights: [Using datatables|http://balusc.blogspot.com/2006/06/using-datatables.html]. Checkout the chapter titled "Select multiple rows". Make use of this knowledge to select specific rows in the popup and gather them all in the bean.
    Additional note: don't use Javascript to read/add/save data. It's pointless. Only use JS to open the popup window pointing to a JSF page with the datatable inside.
    Edited by: BalusC on 14-mei-2008 16:36

  • Can I cut my GUI into "hotspots" using Java code?

    I'm working on the GUI of my app. I learned how to do the GUI by having the frame, and dropping the necessarry components (i.e: buttons, text boxes, etc) onto the frame.
    Well, my graphics-guy made me a nice looking skin for the application, and he already drew in the buttons, etc, so they look nice. Is it possible for me to "cut up" the graphic into 'hotspot' areas, sort of like you do with web pages, and to have the actionListener code from each of my buttons be 'attached' to that hotspot area on the graphic?

    Don't know, whether it's possible to use "hotspots".
    But what's about the possibility of invisible components placed over your graphic.
    i.g.
    JButton b = new JButton();
    b.setBorder(null);              // no border
    b.setContentAreaFilled(false); // invisible Background
                                   // and so on.You can hide nearly any part of any component but its still usable.
    (Add listeners, edit text areas ...)
    Use your graphic as background of (invisible?) Frame, the rest you've already done.
    Only a suggestion, i don't know whether there is a more professional solution.

  • How to change the properties of a directory using java code

    Hai All,
    I need to change the properties of directory( websharing).
    Can i do this using java code.
    Regards,
    Charan

    I need to change the properties of
    directory( websharing).
    an i do this using java code.Depends on whether the server has a Java API to do it. Most likely it hasn't.

  • How to read data from the excel file using java code.

    Hi to all,
    I am using below code to getting the data from the excel file but I can't get the corresponding data from the specific file. can anyone give me the correct code to do that... I will waiting for your usefull reply......
    advance thanks....
    import java.io.*;
    import java.sql.*;
        public class sample{
                 public static void main(String[] args){
                      Connection connection = null;
                          try{
                               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                               Connection con = DriverManager.getConnection( "jdbc:odbc:Mydsn","","" );
                               Statement st = con.createStatement();
                               ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );
                               System.out.println("sample:"+rs);
                                  ResultSetMetaData rsmd = rs.getMetaData();
                                  System.out.println("samplersd:"+rsmd);
                               int numberOfColumns = rsmd.getColumnCount();
                                  System.out.println("numberOfColumns:"+numberOfColumns);
                                   while (rs.next()) {
                                            System.out.println("sample1:"+rs);
                                            for (int i = 1; i <= numberOfColumns; i++) {
                                                 if (i > 1) System.out.print(", ");
                                                 String columnValue = rs.getString(i);
                                                 System.out.print(columnValue);
                                            System.out.println("");
                                       st.close();
                                       con.close();
                                      } catch(Exception ex) {
                                           System.err.print("Exception: ");
                                           System.err.println(ex.getMessage());
                        }

    1: What is the name of the excel sheet?
    2: What is printed in this program? null ? anything?
    error?Excel file name is "sample.xls" I set excel file connectivity in my JDBC driver(DSN). Here in my program I am not giving that excel file name. I am giving only that excel sheet name. that is followed
    ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );The output of this program is given bellow.
    sample:sun.jdbc.odbc.JdbcOdbcResultSet@1b67f74
    samplersd:sun.jdbc.odbc.JdbcOdbcResultSetMetaData@530daa
    numberOfColumns:2

  • Html tags - how to add a blank line

    Hi there,
    can anyone tell me how to add a blank line into a page using one of the html tags ?
    thanks,
    Malcolm.

    You can use the <br> tag for a line break. Also   for space.
    Regards,
    Arun

  • Merge LiveCycle Form with XML using JAVA

    Hello.
    I am trying to find out how to merge non-interactive form with XML (using JAVA) so the users can see the final output form with the data filled in.
    What are my choices..?
    So far, I have created the interactive forms as template using LiveCycle 8 and wrote ASP.NET code to extract data and store it in SQL database when the user fill out and submit the form.
    It works great but another agency wants to access the form as well.
    They told us that they will create the XML themselves from the database, so they just need to combine the form with XML to display it (non-interactive form).
    They want to use JAVA but I am not sure how to do that...
    Any suggestion?

    Assuming that you start with XML in an org.w3c.dom.Document that stores the XML data. Before you can merge it into a form, you have to convert it to a com.adobe.idp.Document object. TO convert a org.w3c.dom.Document to a com.adobe.idp.Document object -- use the following Java code:
    private Document convertDataSource(org.w3c.dom.Document myDOM)
    byte[] mybytes = null;
    try
    //Create a Java Transformer object
    TransformerFactory transFact = TransformerFactory.newInstance();
    Transformer transForm = transFact.newTransformer();
    //Create a Java ByteArrayOutputStream object
    ByteArrayOutputStream myOutStream = new ByteArrayOutputStream();
    //Create a Java Source object
    javax.xml.transform.dom.DOMSource myInput = new DOMSource(myDOM);
    //Create a Java Result object
    javax.xml.transform.stream.StreamResult myOutput = new StreamResult(myOutStream);
    //Populate the Java ByteArrayOutputStream object
    transForm.transform(myInput,myOutput);
    // Get the size of the ByteArrayOutputStream buffer
    int myByteSize = myOutStream.size();
    //Allocate myByteSize to the byte array
    mybytes = new byte[myByteSize];
    //Copy the content to the byte array
    mybytes = myOutStream.toByteArray();
    catch (Exception e) {
    System.out.println("The following exception occurred: "+e.getMessage());
    //Create a com.adobe.idp.Document object and copy the
    //contents of the byte array
    Document myDocument = new Document(mybytes);
    return myDocument;
    THen you can merge myDocument into the Form using renderPDFFOrm:
    FormsResult formOut = formsClient.renderPDFForm(
    formName, //formQuery
    myDocument, //inDataDoc
    pdfFormRenderSpec, //PDFFormRenderSpec
    uriValues, //urlSpec
    fileAttachments //attachments
    Hope this helps!

Maybe you are looking for