Changing the encoding attribute in xml output

We are creating an xml file using:
vc_string_clob := dbms_xmlgen.getxml('select * from mytable');
then opening the file with UTL_FILE.FOPEN('dir','filename','W',31767)
then parsing through vc_string_clob and using UTL_FILE.PUT_LINE to write to the file.
This all works fine, expect the header of the XML file is <?xml version="1.0"?> and our users need it to be <?xml version="1.0" encoding="ISO-8859-1"?>
Is there a function within dbms_xmlgen that will allow me to change this?
I'm thinking I can use brute force to change it, but I'm sure there is a 'more correct' way to go about it.
Thank you,
Jill Jacomine

Hi Jill,
Welcome to the forum.
There are easier methods to output XML to a file, rather than using line-by-line UTL_FILE operations.
For example :
DECLARE
xml_result xmltype;
doc        dbms_xmldom.DOMDocument;
BEGIN
xml_result := dbms_xmlgen.getXMLType('SELECT * FROM scott.dept');
doc := dbms_xmldom.newDOMDocument(xml_result);
dbms_xmldom.writeToFile(doc, 'TEST_DIR/my_file.xml', 'ISO-8859-1');
dbms_xmldom.freeDocument(doc);
END;
/or,
DECLARE
xml_result xmltype;
xml_prolog clob := '<?xml version="1.0" encoding="ISO-8859-1"?>'||chr(10);
BEGIN
xml_result := dbms_xmlgen.getXMLType('SELECT * FROM scott.dept');
dbms_xslprocessor.clob2file(xml_prolog || xml_result.getClobVal(), 'TEST_DIR', 'my_file.xml');
END;
/Both will produce :
<?xml version="1.0" encoding="ISO-8859-1"?>
<ROWSET>
  <ROW>
    <DEPTNO>10</DEPTNO>
    <DNAME>ACCOUNTING</DNAME>
    <LOC>NEW YORK</LOC>
  </ROW>
  <ROW>
    <DEPTNO>20</DEPTNO>
    <DNAME>RESEARCH</DNAME>
    <LOC>DALLAS</LOC>
  </ROW>
  <ROW>
    <DEPTNO>30</DEPTNO>
    <DNAME>SALES</DNAME>
    <LOC>CHICAGO</LOC>
  </ROW>
  <ROW>
    <DEPTNO>40</DEPTNO>
    <DNAME>OPERATIONS</DNAME>
    <LOC>BOSTON</LOC>
  </ROW>
</ROWSET>Hope that helps.

Similar Messages

  • How to set the encoding of an XML-document

    I need to change the encoding of an xml-document.
    When I convert the document into a string, UTF-8
    is used, I want to use ISO-8859-1.

    use this in your identity transform:
    transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");

  • How to change the Encoding type of a XML

    Hi all,
    I'm having a XML(generated at run time) with UTF-8 Encoding. If I'm going to parse it, getting an error saying "*Document root element is missing*".
    If I change the encoding to ANSI, it parses without error.
    How can I change the encoding type of a documnet ?
    Any comment welcome.
    Kaushalya

    There's no such thing as the "encoding of a String". If you produced a String from a sequence of bytes using the wrong encoding, you may not be able to repair that problem by hacking about in your code. You're better off to produce the String using the correct encoding in the first place. Read this for more information about XML and encodings as you appear to be misunderstanding basic concepts:
    [http://skew.org/xml/tutorial/]

  • Changing character encoding in ps xml pub. from utf-8 to iso-8859-1

    I am using xml publisher to generate a report in a pdf format, now my problem is user has entered a comment which is not supported by utf but in iso-8559-1 its working fine,
    I tried to change the encoding in people code, xml doc file ,schema and xliff file but still the old formatting exist,should I change somewhere else.
    Following the error i get when trying to generate pdf:"Error generating report output: (235,2309)Error occurred during the process of generating the output file from template file, XML data file, and translation XLIFF file.".The parser is not able to recognise with utf-8 encoding.

    I had the same issue. I created the xml through rowset and used string substitute function and its working.
    Sample:
    &inXMLDoc = CreateXmlDoc("");
    &ret = &inXMLDoc.CopyRowset(&rsHdr);
    &sXMLString = &inXMLDoc.GenFormattedXmlString();
    &sXMLString = Substitute(&sXMLString, "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""ISO-8859-1""?>");
    hope this helps!
    GN.

  • How to generate the encoding attribute

    Hi,
    After reading a lot of posts on this forum and trying out suggestions on both 9.2 and 10G databases my question is stil unanswered. So I thought I'd ask my question again.
    Original post is here (dbms_xmlgen how to generate encoding attribute
    I'm currently generating XML using the dbms_xml packages. But same problem exists when using sql/xml functions.
    I get this header :
    <?xml version="1.0"?>
    My database has the WE8MSWIN1252 characterset. So I want the header to be:
    <?xml version="1.0" encoding="windows-1252"?>
    My question is how can I generate the xml header automatically, depending on the database characterset?
    The code has to work on 9.2 and 10G. I see 2 possible solutions.
    1 The encoding attribute value is generated automatically
    2 I generate it myself but then I need a to translate the database characterset name to the proper value for the encoding attribute value.
    Rene

    You could write (indeed as you mentioned option in 2) your own, for instance, as shown here:
    Re: Concatenation, Attributes, and Processing Instruction
    and/or use XMLROOT
    but that said, you can't use XMLROOT in 9.2 yet.
    but based on your requirements it is not easy / a lot of work to do, although I wonder what you are trying to achieve and don't forget that if you pick the database characterset you will probably overrule situations based on:
    (http://download.oracle.com/docs/cd/B19306_01/server.102/b14225/ch3globenv.htm#i1006415)
    NLS_SESSION_PARAMETERS shows the NLS parameters and their values for the session that is querying the view. It does not show information about the character set.
    NLS_INSTANCE_PARAMETERS shows the current NLS instance parameters that have been explicitly set and the values of the NLS instance parameters.
    NLS_DATABASE_PARAMETERS shows the values of the NLS parameters for the database. The values are stored in the database.
    or in other words if NLS settings are manually changed within a session, instance or database context.
    Message was edited by:
    Marco Gralike

  • How to change the encoding value in jdom?

    When I create a new xml file by using jdom, the encoding value of xml is "UTF-8"
    (<?xml version="1.0" encoding="UTF-8"?>).
    How can I change encoding value to "big5"??
    Thanks

    Use this method (JDom API)
    XMLOutputter.setEncoding(java.lang.String encoding)
    Regards,
    Darren

  • Error while changing the Display Attribute into Navigational Attribute

    Hi all.. Gud Mrng.
    I was changed the attribute (product) from display attribute into navigational attribute and while save and activating the info object it is not getting activated and it is throwing the below error message.
    Error Message: u201CThe Info object is being used in several data targetsu201D
    My Questions:
    i)     Do I need to delete the data from all the data targets (where this info object is using)??
    ii)     Do I need to delete data only from the main info object (Zmaterial)? Is this single action enough?
    Please suggest me which action I need to follow & What are the precautions need to take while changing the Display Attribute (product) into Navigational attribute of info object (Zmaterial).
    Thanks in advance.
    Thanks & Regards,
    B Venugopal

    Hi Garima
    Only in case of key figures we cannot change it from display to navigational.
    If the info object is a characteristics then in the General tab of the info object if you select 'attribute only' then the iobj would be a display attribute only. If you leave it unmarked then you can use the iobj as a navigational atribute.
    I am sure you know that these settings only mean if a IOBJ can be used as display or navigational.  To  use it as a navigational within another object you will have to change the settings from 'DIS' to 'NAV' for the said info object in the 'Attributes' tab of its parent info object.
    Further if you use the parent info object in any data target / infio provider you will have to further mark the info object as 'navigational' while defining the attrbute of the said data target / info provider. The info object gets displayed in the data target / info provider attribute properties as 'parent IOBJ_info object'
    Cheers
    Umesh

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • Changing the ImageData attribute of a list viewnode..

    Hi,
    I am trying to change the Image Data attribute of a list view node after
    a user clicks on it. But it just doesnot get reflected in the listview.
    UpdateFieldFromData()/UpdateWindow() donot do the job either.
    I could ofcourse clone the node, change it's ImageData, remove the old
    node, insert the new one and then do a SetViewNodes(), but that is really
    not the solution!!
    Has anyone been in this situation before??
    Thanks in advance.
    Inderjyot Singh
    Indus Consultancy Services
    201-261-3100 x232
    [email protected]

    I discovered what was wrong with what I did.
    You have to an UpdateFieldFromData() on the DisplayNode object of the
    listview to get refreshed. Doing an UpdateWindow/UpdatefieldFromData on
    the ListView widget doesnot work!!
    Thanks.
    Inderjyot Singh
    Indus Consultancy Services
    201-261-3100 x232
    [email protected]
    -----Original Message-----
    From: Lee Wei [SMTP:[email protected]]
    Sent: Friday, February 13, 1998 9:29 AM
    To: Singh, Inder Jyot
    Subject: Re: Changing the ImageData attribute of a list view node..
    I tried the situation you described and saw the same problem.
    You should probably let Tech Support know and file a bug.
    Lee Wei
    At 09:25 AM 2/13/98 PST, you wrote:
    >
    Hi,
    I am trying to change the Image Data attribute of a list view node after
    a user clicks on it. But it just doesnot get reflected in the listview.
    UpdateFieldFromData()/UpdateWindow() donot do the job either.
    I could ofcourse clone the node, change it's ImageData, remove the old
    node, insert the new one and then do a SetViewNodes(), but that is really
    not the solution!!
    Has anyone been in this situation before??
    Thanks in advance.
    Inderjyot Singh
    Indus Consultancy Services
    201-261-3100 x232
    [email protected]

  • How to change the date format in xml form?

    hi,
    How to change the date format in xml form?
    For example:  11/20/2008 3:00:03 PM    ->   11-20 03:00
    Any opinions greatly appreciated!
    Thanks.
    Edited by: ke wenxing on Dec 2, 2008 8:33 AM

    You could go to System - User Profile - Own Data would take you to the "maintain user profile screen"
    Click the defaults button and change the date format.This changes date format for all the dates in your login.

  • Changing the naming attributes of o to ou

    Hi ,
    I need to change the naming attribute of 'o' to 'ou' so that whenever i create an organisation it will be referred to ou instead of o .Is there a way to do it?

    I don't know how to do that, but it sounds awfully dangerous to be making a fundamental change like that. Why not just use the OrganizationalUnit objectclass instead? I took a quick look at the schema and they use the same attributes, except for "o" and "ou".
    Just my $.02,
    Roger S.

  • Changing the encoding to 256 kbps from the standard 128 kbps

    I just read an article on the Internet about earbuds, especifically the Shure 4c, in which it was "highly reccomended" to change the encoding to higher levels such as 256 kbps from the "standard" 128 kbps.
    The question is, once you have all your songs in iTunes downloaded at the standard 128 kbps, how do you change the encoding to 256 kbps, without deleting everything and transfering all your CDs, etc, all over again? Can it be done without the obvious, do it all over?
    Thanks

    Pedro, this will not be possible. You can't convert a lower bitrate to a higher one & gain anything in quality. The maximum data has already been compressed & removed under the lower bitrate & can't be put back. If you truly want the benefits of the higher bitrate, it would be much better to re-import your CD's at the 256 bitrate. Post back if you have any questions.

  • Why JSTL change the encoding of response?

    Dear all,
    I use JSTL to display multiple language, and it can work fine. I also have a servlet to let the user to select the display language. All the request and response encoding is set to UTF-8, but I found that when user choose language to Chinese, and the servlet set the Locale to ZH, and then, all the jsp file which use JSTL to display message, the response is set to "GB2312"!
    Why this happen? because the response encoding is gb2312, so I cannot get the user inputted Chinese character! I want still reserve the UTF-8, how can I do that? I just found that webapp 2.4 can set locale-encoding-mapping, but I am using tomcat4.1.4, which does not support 2.4.
    Any advice will be appreciate.
    Lichunlin

    Hi, everyone,
    I find that the setLocale method of Reponse will change the response encoding automatically according to the locale, for example, the page encoding is UTF-8, but after I set locale to "CN"(china), the encoding is changed to "GB2312", but I still want it is "UTF-8".
    So I have to change the message tag source code, to change the encoding back after the setLocale method invoke, it is not so good, but it can work now.
    Could you have any other advice? Thank you very much.
    Lichunlin
    Dear all,
    I use JSTL to display multiple language, and it can
    work fine. I also have a servlet to let the user to
    select the display language. All the request and
    response encoding is set to UTF-8, but I found that
    when user choose language to Chinese, and the servlet
    set the Locale to ZH, and then, all the jsp file which
    use JSTL to display message, the response is set to
    "GB2312"!
    Why this happen? because the response encoding is
    gb2312, so I cannot get the user inputted Chinese
    character! I want still reserve the UTF-8, how can I
    do that? I just found that webapp 2.4 can set
    locale-encoding-mapping, but I am using tomcat4.1.4,
    which does not support 2.4.
    Any advice will be appreciate.
    Lichunlin

  • How Can i change the Encoding for Mp3 cds???

    I am curious on how i can chane the Encoding With on i tunes.....The reason is im heavily into car audio and always like to see the names of the bands and song title come up when i play them in my car. Ive noticed certain bands show up on the screen of my cd player..but others say no artist. Ive Also noticed some have a different encoding such as Lame 3.96....... Does Anyone Know How to Change the Encoding With....Or Make it Show up on my car cd player?

    Do you mean you'd rather import using say AAC for instance instead of mp3?
    Go to iTunes Preferences (+,)>advanced>importing>import using> change to which ever format you desire.
    When you burn the cd, check "include CD text" under the audio section if you're burning an audio CD.

  • Change the field attribute of a field in data source - 0CRM_SALES_ACT_1

    Hi ,
    I have a data source named 0CRM_SALES_ACT_1 in CRM system.
    The fields PLANNED_TS_FROM and PLANNED_TS_TO are hidden fields i.e. the field attribute is 'A' - Field in OLTP and BW Hidden by SAP.
    Following are my doubts:
    1. Whether the values of these fields will be extracted into BW or it will not be?
    2. How do I change the fields attribute value of these fields(its standard data source)?
    3. Is there any SAP note to do this ?
    4. If the above doesn't exisits, then should I go for a append structure to the standard data source?
    Please help me.
    Regards,
    Ahmed.

    Hi,
    U can unhide ur fields in RSA6 and then replicate the datasource in BW. These fileds will come in BW.
    You cant change the attribute value for STD DSO.
    No SAP note for the same.
    You can append the datasource with the new fields with the attribute you want and hide the std. fields then goto BW and replicate it. You can then map it with the BW fields as you want.
    *Assign points if helpful.

Maybe you are looking for

  • Unit Testing and Integrating testing In HR

    Dear Sap Gurus, Would you be kind enough to  give me an example of unit testing and integrating testing??  what do you test, eg..TC and what else.. what happened.??. And also an example of Integrating testing  ..and an example ....I know what unit an

  • How to have both Single and Mutilple Selection in a table?

    Hi , I have a page with an advanced, there is a multiple selection for the table for deleting row. Now I want to have a single selection column for other purpose. But it does not seem that we can have both in a table. If I implement SingleSelection m

  • BCM4331 on MBP 9,1

    Hi, I'm trying to install arch on my macbook pro 9,1 (mid-2012) but I need wifi working for the installation for a network connection. I viewed almost all the wikis and tried nearly everything I saw. The last thing I tried was installing the broadcom

  • WRT300N connection issue similarities??

    Hello everyone. I just bought a 300N router as an upgrade from a linksys B router, before checking these forums and seeing all the issues that everyone else has with them with the wireless connection dropping out. At the same time as the router purch

  • MAgnifying a Text Selection

    I have to create a trng document on an IRS form. The form is a PDF, I am needing to magnify a portion of the text. Almost like enlarging a sentence so it si easier to read when I place it in the . Any ideas on how to do this. I have acrobat 7 pro. An