Help on writing xml

Hi i am trying to get this      
bw.write("<mcq_QuestionType QID=" "+count+" ">");
to print out as this in my xml file
<mcq_Questiontype QID="1">
can anyone please help me.......
what i get is
<mcq_Questiontype QID=1>

Hi,
To solve this kind of problem , you need to use escape character to display special characer like this. Normally, double quotes are used to represent the string, in order to avoid those default meaning we need to use escape characer "\".
Hope that helps.
Best Luck,
Senthil Babu
Developer Technical Support
SUN Microsystems
http://www.sun.com/developers/support/

Similar Messages

  • Need help in writing XML file!!!

    dear friends:
    I'm a learner in J2ME, and I understood how to parse a simple XML document with SAX parser, but it don't supply methods to write a XML file or store my data to a XML file.
    Somebody can tell me how to do?
    Thanks in advance.

    hello
    you can also read this:
    http://www.cafeconleche.org/books/xmljava/
    nice stuff !
    peace

  • Help in Writing XSLT

    Hello guys,
    I need help in writing XSLT.I have a XML structure as below.
    <PushEventResult>
         <pushEventDT>
              <id>XX</id>
              <serialNumber>111</serialNumber>
              <Mpxn>1X1</Mpxn>
              <EventData>
                   <alarmDtime>xxx</alarmDtime>
                   <alarmType>UP</alarmType>
                   <additionalData>dummy</additionalData>
              </EventData>
              <EventData>
                   <alarmDtime>xxx</alarmDtime>
                   <alarmType>DOWN</alarmType>
                   <additionalData>dummy</additionalData>
              </EventData>
         </pushEventDT>
    </PushEventResult>
    With XSLT I need to transform it in to this format.
    <PushEventResult>
         <pushEventDT>
              <id>XX</id>
              <serialNumber>111</serialNumber>
              <Mpxn>1X1</Mpxn>
              <EventData>
                   <alarmDtime>xxx</alarmDtime>
                   <alarmType>UP</alarmType>
                   <additionalData>dummy</additionalData>
              </EventData>
              </pushEventDT>
         <pushEventDT>
              <id>XX</id>
              <serialNumber>111</serialNumber>
              <Mpxn>1X1</Mpxn>
              <EventData>
                   <alarmDtime>xxx</alarmDtime>
                   <alarmType>DOWN</alarmType>
                   <additionalData>dummy</additionalData>
              </EventData>
         </pushEventDT>
    </PushEventResult>

    A possible attempt will be this set of templates.
    <xsl:template match="PushEventResult">
        <xsl:copy>
            <xsl:apply-templates select="pushEventDT" />
        </xsl:copy>
    </xsl:template>
    <xsl:template match="pushEventDT">
        <xsl:for-each select="EventData">
            <pushEventDT>
                <xsl:call-template name="const_struct" />
                <xsl:copy-of select="." />
            </pushEventDT>
        </xsl:for-each>
    </xsl:template>
    <xsl:template name="const_struct">
        <xsl:apply-templates select="preceding-sibling::*[not(name()='EventData')]" mode="const" />
    </xsl:template>
    <xsl:template match="*" mode="const">
        <xsl:copy-of select="." />
    </xsl:template>

  • Writing XML files

    Hello all
    There's a vast amount of information on the java.sun.com site about parsing XML files:
    * creating DOM trees in memory from an XML file
    * setting up event handlers to be called when an XML file is parsed
    * transforming XML files using XSL.
    However, I can find very little information anywhere about writing XML files in the first place! I'm already aware of two ways to do this:
    (1) create a DOM in memory and write this to a file. If the data is large, though, this isn't feasible.
    (2) just output the XML elements directly to some file as text. This doesn't take account of the encoding, or special characters, and the document is not necessarily then syntactically valid.
    Is there some API which I haven't yet come across that is designed specifically for writing XML data to files? If it's built in to Java 2, then goodness knows how I've missed it all this time; if it's third-party, I'd be grateful for any links.
    Thanks for your help
    Rich Fearn

    I know pastes can be horrible, but this is a working example which I find useful: SAX XML output ;)
    import java.io.*;
    // SAX classes.
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    //JAXP 1.1
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.sax.*;
                    //AlphabetXMLOut(file, alphabets);
    class AlphabetXMLOut {
            public void run(){
                    try{
                            FileOutputStream fos = new FileOutputStream("output.xml");
                            PrintWriter out = new PrintWriter(fos);
                            StreamResult streamResult = new StreamResult(out);
                            // PrintWriter from a Servlet
                            //PrintWriter out = response.getWriter();
                            //StreamResult streamResult = new StreamResult(out);
                            SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
                            // SAX2.0 ContentHandler.
                            TransformerHandler hd = tf.newTransformerHandler();
                            Transformer serializer = hd.getTransformer();
                            serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
                            serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
                            serializer.setOutputProperty(OutputKeys.INDENT,"yes");
                            hd.setResult(streamResult);
                            hd.startDocument();
                            AttributesImpl atts = new AttributesImpl();
                            // USERS tag.
                            hd.startElement("","","USERS",atts);
                            // USER tags.
                            String[] id = {"PWD122","MX787","A4Q45"};
                            String[] type = {"customer","manager","employee"};
                            String[] desc = {"Tim@Home","Jack&Moud","John D'oe"};
                            for (int i=0;i<id.length;i++){
                                    atts.clear();
                                    atts.addAttribute("","","ID","CDATA",id);
    atts.addAttribute("","","TYPE","CDATA",type[i]);
    hd.startElement("","","USER",atts);
    hd.characters(desc[i].toCharArray(),0,desc[i].length());
    hd.endElement("","","USER");
    hd.endElement("","","USERS");
    hd.endDocument();
    fos.close();
    }catch (IOException e){
    System.err.println ("Unable to write to file");
    System.exit(-1);
    }catch (TransformerConfigurationException tce){
    System.err.println("Error in: TransformerConfigurationException");
    }catch (SAXException spe) {
    // Error generated by the parser
    System.err.println("Error in: (SAXException");
    // Use the contained exception, if any
    Exception x = spe;
    if (spe.getException() != null)
    x = spe.getException();
    x.printStackTrace();
    -Hope this helps

  • Need Help in writing a UDF

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1)         batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2)         lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3)        How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    Thanks in Advance,
    Sreedhar.

    Hi,
    Following with my query I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);     
    DataBaseResult resultSet = accessor.execute(InputPayload);
         for(Iterator rows = resultSet.getRows();rows.hasNext();){  
         Map rowMap = (Map)rows.next();
         Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
          catch (Exception e) {}
          finally {
                  if (accessor != null)
                  accessor.close();
           result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Help in writing a query!

    Dear All,
    My database is 11gR2 on Linux.
    I am struck in writing a difficult query, need help from your guys.
    I have a table, an application is controlling the columns of this table. Columns are added by the application.
    This is the structure of the table:
    create table imran_test(
    2 username varchar2(100),
    3 layer1 number(1),
    4 layer2 number(2),
    5 layer3 number(2));
    -- where layer1, layer2, layer3.... are increased up to layer 22 and could be increased more...
    Now each username will have 1 in any one of the layer, and all other layers will have 0
    Like if I consider the above table this could be the sample data:
    imran 1 0 0
    hafeez 0 1 0
    james 0 0 1
    Now the result my query should return is:
    select username, <column name where value is 1> and value of it, as per sample data, this should be return by the query:
    imran layer1 1
    hafeez layer2 1
    james layer 3 1
    Note: Please remember the columns are not fixed, they are added/altered by application.
    Regards,
    Imran

    The table design is incorrect as it is not in 3NF and has a repeating group
    You should correct the 'design' first or turn the layer... columns in a VARRAY.
    Also my feeling is you should change your subject line 'Help in writing a query!' in 'Write my query' as that is what you actually ask, and leave out the exclamation mark.
    Basically you dump everything in this forum, and being a bit less demanding might suit you better.
    Also you still act rude by not marking your questions as answered.
    Change that
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 1-apr-2012 12:09

  • Help with writing a formula

    Hi all,
    I am creating a report, and need help with writing a formula...
    I am creating a report that shows how many visits/touches our reps have made to various grade accounts. It is broken down by calendar week, and I currently have a weekly "goal" number set that the reps have to meet. That "goal" number increases each week to keep a running total. (example: week 1: 7, week 2: 14, week 3: 21)
    I have created some different formulas and one is this:
    SUM("Activity Metrics"."# of Activities" BY Date."Calendar Week")
    What this shows me is how many "visits" there are per calendar week to customers, however it show me the total for all reps per week.
    What I need is that total to show, but totaled for each rep individually.
    What I was trying is this:
    SUM("Activity Metrics"."# of Activities" BY Date."Calendar Week") BY Employee."Employee Name"
    But...I keep getting an error.
    Any suggestions?
    I have the reporting book by Lairson, and have been referring to it...but my brain at this point is fried.
    Thanks in advance for any help...(please forgive...I am new to OnDemand, and I am sure this is easy)

    Thanks for helping!
    I created this formula as a column: SUM ("Activity Metrics"."# of Activities" BY Date."Calendar Week"), it is called "total number of visits per week" and it shows the totaled number of visits that all the reps have done per calendar week. For example: Week 1: 10 visits, Week 2: 37 visits, Week 3: 20 visits.
    What I would like to do is take that column and break it down further, to show instead how many visits per week by sales rep there have been
    So what I was trying was to take the "total number of visits per week" (SUM ("Activity Metrics"."# of Activities" BY Date."Calendar Week")) and use "Activity Owner" (Employee."Employee Name") to break it down further.
    What I need to use is the total number of visits each rep has per calendar week.
    I think I am getting the error because you can't use "BY" twice in a formula?

  • Help with writing a batch file

    Hi :
    does anyone know anyplace online that I can get help in writing batch files?? I have never worked much with batch files before....
    any help is greatly appreciated
    thnx

    I suppose, since you're in a Java forum, you need batch files to load java applications.
    If you use windows :
    go to ms console (start/run/"cmd")
    type edit mybatch.bat
    write your command to load a java application, something like
    java myclass.class
    save and exit.
    Be sure the bat file and the class are in the same folder.
    And make certain you've set the classpath, and path variables correctly.
    If this was what you needed and you need more help just ask.
    (In this case it could be better to make executable jars)
    If you wanted to know about linux batches, it works pretty the same way.

  • "encoding = UTF-8" missing while writing XML file using file Adapter

    Hi,
    We are facing an unique problem writing xml file using file adapter. The file is coming without the encoding part in the header of xml. An excerpt of the file that is getting generated:
    <?xml version="1.0" ?>
    <customerSet>
    <user>
    <externalID>51017</externalID>
    <userInfo>
    <employeeID>51017</employeeID>
    <employeeType>Contractor</employeeType>
    <userName/>
    <firstName>Gail</firstName>
    <lastName>Mikasa</lastName>
    <email>[email protected]</email>
    <costCenter>8506</costCenter>
    <departmentCode/>
    <departmentName>1200 Corp IT Exec 8506</departmentName>
    <businessUnit>1200</businessUnit>
    <jobTitle>HR Analyst 4</jobTitle>
    <managerID>49541</managerID>
    <division>290</division>
    <companyName>HQ-Milpitas, US</companyName>
    <workphone>
    <number/>
    </workphone>
    <mobilePhone>
    <number/>
    </customerSet>
    </user>
    So if you see the header the "encoding=UTF-8" is missing after "version-1.0".
    Do we need to configure any properties in File Adapter?? Or is it the standard way of rendering by the adapter.
    Please advice.
    Thanks in advance!!!

    System.out.println(nodeList.item(0).getFirstChild().getNodeValue());

  • Need help for writing extract program

    hi
    i need help for writing extract program to retriew data from legacy system.
    i already developed bdc programs for me31k and me21.
    my requirement is to write extract program s for those t.codes.
    to retriew data from legacy system and stored in flat file.

    i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
    You haven't posted ANY 'java program' for us to help with.
    The forum is NOT a coding service. It is to help you with YOUR code.
    Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
    If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment.

  • Need helping in writing query for finding percentage of duration

    Can any one please help in writing query for this.
    The table is like this :-
    ID     Region     Month     Duration
    I1 R1     Jan     80
    I2     R2     Jan     70
    I3     R1     Jan     70
    I4     R3     Jan     40
    I5     R1     Feb     80
    I6     R2     Feb     30
    I7     R3     Mar     100
    I want to write a query to find
    % of duration for each and every region against each and every month.
    Please help in solving this query. I am in urgent need of this.
    Thanks in advance.

    I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
    Nicolas.

  • What is the advent of writing xml mapping for servlet in tomcat4.1

    what is the adventage of writing xml mappings for servlet in tomcat4.1? why dont we write in tomcat 3.1?

    what is the adventage of writing xml mappings for
    servlet in tomcat4.1? why dont we write in tomcat 3.1?Tomcat 3.1 doesn't support it because it was not a common practice then. Tomcat 4.1 deployments were made J2EE compliant. Mapping in XML has an advantage of having a proper DTD for validation, which would be known to all. It serves as a common standard irrespective of the server you use.

  • Writing XML in General

    Ok so I am new to this idea. I was wondering can anyone tell me where I can find a good example of Java writing XML using the DOM model.
    I cannot figure out how to output my XML Document to a file.

    Ok, is there anyway to get the file to be in better XML format? Currently everything is ouput as one long string
    Something like this
    <?xml version="1.0" encoding="UTF-8"?><Top The="Attrbiute For Top"><Next><Last An="Element for this Last">I am a TextNode</Last><Last>I am a TextNode as Well</Last></Next></Top>I want it to appear like this
    <?xml version="1.0" encoding="UTF-8"?>
    <Top The="Attrbiute For Top">
         <Next>
              <Last An="Element for this Last">I am a TextNode</Last>
              <Last>I am a TextNode as Well</Last>
         </Next>
    </Top>

Maybe you are looking for