XML formatting not fine in a text editor
Hello Experts,
am generating an xml file through a java program using javax.xml.parsers.
Following is the format of file (say for eg) generated when i see in notepad
<root><tag1>val1</tag1><tag2>val2</tag2></root>
which is not required. I want the file to be in the following format.
<root>
<tag1>val1</tag1>
<tag2>val2</tag2>
</root>
When the file is viewed in any browser, it is fine but is getting messy in a text editor.
Please Help. It would be really appreciated.
Regards
Priya
idTransform2.setOutputProperty("indent", "yes");
"indent" property is used for that purpose,use the following program.
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
public class SocketExample
* @param args
* @throws IOException
* @throws ParserConfigurationException
* @throws TransformerException
public static void main(String[] args) throws IOException, ParserConfigurationException, TransformerException
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = fact.newDocumentBuilder();
Document doc = parser.newDocument();
Node root = doc.createElement("request");
doc.appendChild(root);
Node Last_Name_Node = doc.createElement("Last_Name");
root.appendChild(Last_Name_Node);
Last_Name_Node.appendChild(doc.createTextNode("Last_Name"));
Node Title_Node = doc.createElement("Title");
root.appendChild(Title_Node);
Title_Node.appendChild(doc.createTextNode("Title"));
// setting Servcie Address1
Node Service_Address1_Node = doc.createElement("Service_Address1");
root.appendChild( Service_Address1_Node);
Service_Address1_Node.appendChild(doc.createTextNode("Service_Address1"));
TransformerFactory xformFactory2 = TransformerFactory.newInstance();
Transformer idTransform2 = xformFactory2.newTransformer();
javax.xml.transform.Source input2 = new DOMSource(doc);
javax.xml.transform.Result output2 = new StreamResult(new java.io.FileWriter("d:/webapp.log",true));
idTransform2.setOutputProperty("indent", "yes");
idTransform2.transform(input2, output2);
Message was edited by:
BhavaniRajan
Similar Messages
-
Format XMl to be read in a text editor.
Hi,
I'm using ixml functions to create an xml file. Each element of my document is created using :
<cl_xml_document> ->create_simple_element
I then export it to a file with :
<cl_xml_document>->export_to_file
When the created file is opened with an xml viewer, it appears well presented, every tag is displayed on a seperate line.
However, once opened with a text editor, the whole content is displayed on one line. Is there to format the file with some sort of line seperator?
On debugging, I found out that only one line of its internal table is used to store the data.Welcome to SDN
Try this,
data: temp_str type string.
concatenate '>' cl_abap_char_utilities=>cr_lf '<' into temp_str .
replace all occurrences of '><' in XML_STRING with temp_str.
xml_string is the straing variable to hold the xml .
now use xml_string to show it in texteditor.
Regards
RAja -
Char. formats(Bold, Underline) in Long text editor not visible in ABAP WD
Hi ABAP experts,
Problem:
I have created long text with using bold and under line formats in long text editor (FM TEXT_ EDIT). I am trying to show same text in WebDynpro using READ_TEXT FM. But FM READ_TEXT is getting long text with HTML tags as shown below for bold and underline and it long text showed as same in WebDynpro application with HTML tags.
Long text shown in webdynpro:
Type your message using the form below. When finished, you can
optionally preview your post by clicking on the <H>"Preview"</> tab.
Otherwise, click the <U><H>"Post Message"</></> button to submit your
message immediately.
Is there any function module available to change format and pass to WebDynpro context?
Thanks
Rajesh YadlaThe normal text editor in Web Dynpro won't handle HTML tags (they get safe encoded as you described). In NetWeaver 7.01 we do introduce a FormattedTextEditor that allows for such formatting. There are APIs to convert from SAPScript based texts to the XHTML FormattedText tags.
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/2772f505605447e10000000a422035/frameset.htm -
Div ids are not persisting in rich text editor of CQ5.6
Hi,
I created a rich text widget and I added plugins. I activated "misctools" plugin also. I clicked on "sourceedit" and paste the code which contains ids for divs like -
<div id="onboarding" class="row onboarding-content scroller">
</div>
After that I clicked ok and again I opened the dialog. But I'm unable to see id. It shows only -
<div class="row onboarding-content scroller">
</div>
I also created "htmlRules/serializer/config" nodes of type nt:unstructured under the richtext editor widget. It worked in 5.5 but not in 5.6.
Whats the problem behind this? Please suggest me the solution for this. Let me know if there is any other way to persist div ids in richtext editor of cq5.6
Regards,
Arya.Hi,
Try this to persist div ids in rich text editor in cq5.6
Create a folder structure similar to "/libs/cq/ui/rte/core/HtmlSerializer.js" in apps as "/apps/cq/ui/rte/core/HtmlSerializer.js". Make sure that the folder structure and node types are as same as in libs. Then set "idAttribMode" to "keep" in "_init" function of HtmlSerializer.js. It will work
Thanks,
Arya. -
Font styles in source xml are not set on footnote text
Hi,<br /><br /> could some please help. Not sure what iam missing.<br /><br />Iam using the following code to add footnote for each footnote element in imported xml. Iam running the script after importing xml. footnotes are added successfully but the font styles are not applied to the footnote text. The alerts in the code are as expected.<br /><br />Sample XML:<br /><para>This is begin</para><br /><para>Test footnote one follows<footnote id="f0"><para> FN1 This is<italic>italic</italic> and <bold>bold</bold>.</para><br /></footnote></para><br /><para>This is the second section</para><br /><para>Test footnote two follows<footnote id="f1"><para> FN2 This is<italic>italic</italic> and <bold>bold</bold>.<br /></footnote></para><br /><br />Code:<br /><br />var myGlueCodePath = app.filePath + "/Scripts/xml rules/glue code.jsx"; <br />var myFile = File(myGlueCodePath); <br />app.doScript(myFile); <br /><br />main(); <br />function main(){ <br /> var myDocument = app.activeDocument; <br /> if (app.documents.length != 0){ <br /> var myRuleSet = new Array ( <br /> new processParaBold, <br /> new processParaItalic <br /> ); <br /> with(myDocument){ <br /> var elements = xmlElements; <br /> __processRuleSet(elements.item(0), myRuleSet); <br /> } // End With <br /> } // end if <br /> else{ <br /> alert("No open document"); <br /> } // ende Else <br /><br /> var myXMLElements = new Array; <br /> myXMLElements = myGetXMLElements("//footnote"); <br /><br /> if(myXMLElements.length > 0){ <br /> for(var myCounter = 0; myCounter <= myXMLElements.length-1; myCounter++){ <br /> var myXMLElement = myXMLElements[myCounter]; <br /> var myStartIndex = myXMLElement.texts.item(0).insertionPoints.item(0).index; <br /> var myStory = myXMLElement.texts.item(0).parentStory; <br /> var myFootnoteString = myXMLElement.texts.item(0).contents; <br /><br /> myXMLElement.texts.item(0).contents = ""; <br /> var myInsertionPoint = myStory.insertionPoints.item(myStartIndex); <br /><br /> var myFootnote = myInsertionPoint.footnotes.add(); <br /> myFootnote.insertionPoints.item(-1).contents = myFootnoteString; <br /> } <br /> } <br />} <br /><br />function myGetXMLElements(myXPath){ <br /> var myXMLElements = new Array; <br /> var myRuleProcessor = app.xmlRuleProcessors.add([myXPath]); <br /> try{ <br /> var myMatchData = myRuleProcessor.startProcessingRuleSet(app.documents.item(0).xmlElements.item(0)); <br /> while(myMatchData != undefined){ <br /> var myElement = myMatchData.element; <br /> myXMLElements.push(myElement); <br /> myMatchData = myRuleProcessor.findNextMatch(); <br /> } <br /> myRuleProcessor.endProcessingRuleSet(); <br /> myRuleProcessor.remove(); <br /> return myXMLElements; <br /> } catch (myError){ <br /> myRuleProcessor.endProcessingRuleSet(); <br /> myRuleProcessor.remove(); <br /> throw myError; <br /> } <br />} <br /><br />function processParaBold(){ <br /> var myDocument = app.activeDocument; <br /> this.name = "processParaBold"; <br /> this.xpath = "//footnote/para/bold" <br /> this.apply = function(myElement, myRuleProcessor){ <br /> //myElement.texts[0].applyCharacterStyle(myDocument.characterStyles.item("bol d")); <br /> alert("test bold: " + myElement.texts.item(0).contents); <br /> var myCharacterStyle = myDocument.characterStyles.item("bold"); <br /> if(myCharacterStyle != null){ <br /> alert("bold exists"); <br /> myElement.texts.item(0).applyCharacterStyle(myCharacterStyle); <br /> } <br /> return false; <br /> } <br />} <br /><br />function processParaItalic(){ <br /> var myDocument = app.activeDocument; <br /> this.name = "processParaItalic"; <br /> this.xpath = "//footnote/para/italic" <br /> this.apply = function(myElement, myRuleProcessor){ <br /> //myElement.applyCharacterStyle(myDocument.characterStyles.item("italic")); <br /> alert("test italic: " + myElement.texts.item(0).contents); <br /> var myCharacterStyle = myDocument.characterStyles.item("italic"); <br /> if(myCharacterStyle != null){ <br /> alert("italic exists"); <br /> myElement.texts.item(0).applyCharacterStyle(myCharacterStyle); <br /> } <br /> return false; <br /> } <br />}<br /><br />Thanks
BTW:
If you add document xml tag map style, the style process can be ignored.
Then:
1. Do myStotry.placeXML(justImportedXMLElement);
2. iterate the backward in justImportedXMLElement: get the footXMLElement, skip children;
3.
var myText = footxmlElement.texts[0];
var ix = myText.insertionPoints[0].index;
if(ix == 0){ix = 0;}
var end = myText.insertionPoints[-1].index;
myText = myStotry.insertionPoints.itemByRange(ix-1, end+1);
myText.move(LocatcionOptions.atEnd, myStotry.insertionPoints[ix-1].footnotes.add().insertionPoints[-1])]);
This will be quicker then the upper.
jxswm -
XML Format not poper For receiver File Adapter
I am using XML File to xML File scenario. My receiver is SAP R/3 system. When I send file from another system, It is properly seen in payload but the file is not properly recived on SAP R/3. The XML File appears on single line and when seen on SAP side side the fileis cut after some length. Any help is appreciated.
hi,
>>>The XML File appears on single line and when seen on SAP side side the fileis cut after some length. Any help is appreciated.
it's probably not the XML file file that is corrupter but the way you view the file
do you open it from AL11? if so it does not show the whole file
PI/XI does not cut XML files for sure
Regards,
Michal Krawczyk -
''Duplicate post, continue here - [/questions/776604]''
My PC's motherboard has fried and as such I am working of a beatup laptop. I have a device allowing me to hookup my sATA drive to my laptop and would like to find my bookmarks I store in the bookmark bar without losing the one on my laptop.
Thanks.The bookmarks are stored in a file called places.sqlite in the [[profiles|profile folder]]. This file is not viewable in a text editor.
One way to do this would be to create a new profile (Firefox stores user data in the profile folder), you can then copy the bookmarks and other user data such as passwords to the new profile. You will then have access to the data from the PC and will still have your current laptop data in its own profile.
For details on doing this see [http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows Creating a new Firefox profile on Windows] and [[Recovering important data from an old profile]]. -
Formatting text with a text editor within a website?
My wife wants to use her new iPad 2 to participate in an online community (Ravelry, a knitting and crocheting site). She does a great deal of posting to forums within this community. The text editor for posting in these forums allows users to format their text (bolding, italicize, etc.) as well as to link to other external and internal pages within the site (writers in the forum frequently link to patterns and project images within the site as references in their posts). When she attempts to use the text editor in Ravelry from her iPad, she is unable to select the text she wants to highlight and alter it (by bolding or making it a link). When we select the text, the only options are to copy or cut and we can't, once we've selected the text, tap on the "create a link" button in the text editor. We've tried to use both Safari and Atomic Web browsers, but no luck. Help?
ravelry.com is using WMD-Editor which is a WYWIWYM Markdown editor. Unfortunately it appears their chosen WYWIWYM Markdown editor is no longer or is pretty deprecated.
You as a user are not going to be able to swap out your own editor for use on any website...these editors are hard coded by the website developer...perhaps you could, as already suggested ask them to update to a more robust editor which supports today's standards. Though I doubt you will get far in having them swap out code for this.
A Solution:
Download an alternate browser such as iCabMobile for iOS...I tested ravelry against this browser and the editor does work but is pretty unstable. Funtional but not as intended. Safari cannot load this editor properly at all.
Log into your ravalry account and read their FAQ (http://www.ravelry.com/wiki/pages/UsingTheTextEditor#formatting_bolditalic_lists _and_other_basics)
Simple BBCODE commands for formatting where you do not need to even use the tool bar work fine...just a hassle to memorize.
Hope this helps. -
After applying full scroll bar to the page including header and footer, I have provided content to
the page more than 100 lines and try to format the text from ribbon actions(format text area). On mouse over of font or fore color, the control jumps to the highlighted content area and not able to select the color. The page scrolls down and not able to click
on any action.
Consider this scenario also.
A content editor web part is added toward the bottom of the page.
Text is added to this (direct in the web part, not via a 'content link')
You highlight some text and go to the Markup Style dropdown...
Everything is fine until you hover over the "Paragraph" markup style, and suddenly the page scrolls to the web part you are editing, and you didn't have a chance
to click and apply the "Paragraph" formatting
I have tried testing this with text typed directly into the Content Editor, text pasted in from somewhere else, and text pasted in from somewhere else using "Paste as
Plaintext" option in the ribbon. In each scenario, I get the same results.
Furthermore, I have also tested this in both IE8 and IE9 and get the same results.
I can get it to occur most regularly with trying to apply the Paragraph "Markup Style" but
I've also seen this happen with Font Size (any font size). It's very frustrating since you aren't able to actually apply the formatting you need because the page jumps before you can click. Has anyone experienced this before. Any feedback would
help.Hi,
According to your post, my understanding is that after applying full scroll bar to the page including header and footer, Text editor ribbon actions cause page to automatically scroll down (while applying formatting).
I try to apply full scroll bar to the page including header and footer, the ribbon is missing after I scroll down to the web part. And I cannot apply the "Paragraph" markup style to the content.
I recommend to use the SharePoint core styles to preserve the native functionality and GUI.
By design in SharePoint, the ribbon is always at the top. When you select the content, you can apply the "Paragraph" markup style in the ribbon.
Thanks,
Linda Li
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Linda Li
TechNet Community Support -
How to NOT retain formatting when copying and pasting text
Captivate 7 keeps the formatting from my text sources when I paste into a Text Caption which is not what I need. Anything I could find in the forums where questions relating to "keeping" the source formatting. I don't want this, I want Captivate to keep its text formatting when I paste text into a text caption. I even did a test creating a new project and using one of the Cap 7 themes. If I paste text in the default capture caption style object, it retains the formatting of the copied text source. I have been working with Captivate 7 since a few months now and, until this morning, when I copied and pasted text from another source into my Captivate Text Caption, it retained the format of my Captivate Text Caption object. This is exactly what I need. How can I get this behavior back?
I appreciate any help. Thank you.Hi there
Well, first I would report it as undesired behavior and possibly ask for an enhancement that allows us to right-click and paste without formatting. Do this using the link below:
http://www.adobe.com/go/wish
For now, you have a couple of options.
1. Perform a side trip. Open a text editor such as Windows Notepad or Apple Textpad and paste, then copy back to the clipboard. Then paste the text into the caption. (When pasting into the text editor, formatting is stripped)
2. On Windows machines, you can usually find a clipboard utility that allows you to paste as pure text. In fact, one such application is called PureText.
PureText Home Page (Note that I have no affiliation with them and nothing to gain if you choose to use the product. Just wanted to make you aware of it.)
Cheers... Rick -
Generating an XML formated text file
Hi all
I am a PL/SQL programmer and have no idea about XML :-(
I am using ORACLE 10g and my application generates atleast 100 text files a day for customers. These files are manipulated using Utl_File package and gets data from the DB.These files are tab or comma delimeted. Now company wants to give an option to customers to get the same output in XML format. My understanding is that I need to get information from customers first to make the report template for them and then use some XML parser to get data from DB and give an output using that customer's specific template.
I wanna know, if there is any whitepaper or manual that can guide me step by step. I just need to make an idea how the things can go togather and the sequence of operation. I also wanna use only PL/SQL and not Java at this time.
Rashid
Message was edited by:
rashid68check it out at http://www.orafaq.com/faqxml.htm
-
Portal Rich Text Editor in Firefox 3.5 Not Working
I'm using Oracle Portal Version: 10.1.4.0.0 (Build: 594)
The text item Rich Text editor works fine in IE 6 and has reduced functionality in Firefox 3.0 (scroll doesn't work). I've just updated to Firefox 3.5 and the text editor doesn't work at all now.
The user is presented with a grey box where all the text controls are squashed into the top left hand corner.
The following errors appear in the Error Console :
Error: element.children.tags is not a function
Source File: http://xyz.example.net:7778/images/webword/WebWordMenuToolbar.js
Line: 1
Error: attachEvt is not defined
Source File: http://xyz.example.net:7778/images/webword/buildUI1.js
Line: 76
(I've replaced our server url with http://xyz.example.net)
Has anyone else noticed this? Has anyone got any suggestions on what I can do to investigate/fix it?
Thanks,
Matt
Update :
There is a patch available to potentially fix the Rich Text Editor issues in Firefox
"The Rich Text Editor Does Not Work Correctly In FireFox" - Metalink Doc ID: 456512.1
or you can replace the RTE completely with a 3rd party editor :
"How to integrate third party RTE (FCKeditor) with Oracle Portal" - Metalink Doc ID: 352796.1
Using FCKEditor may well solve the issues but I only use Firefox for development. Our users use IE6 so I don't want to replace the interface unless I have to.
Edited by: Matt Hawkins on Jul 15, 2009 1:58 PMThis is a known issue in both Portal 10.1.4.x and Portal 11.x :
Bug 8708210 (11) NOT ABLE TO RENDER RICH TEXT EDITOR WITH FIREFOX 3.5 BROWSER
This bug is not published on Metalink.
There is no solution yet. Consider to use IE Tab (https://addons.mozilla.org/en-US/firefox/addon/1419) for editing file items until this bug is solved. -
Rich Text Editor not showing up
Hi. I've installed OracleAS 10g Rel 2.
When I try to add text using IE6 the text area is just gray. I have tried to change different attributes in IE but its still gray. I dont know how to debug IE either, I normally use firefox.
Any ideas how I can debug IE, or what I should change on my IE to make the rich text editor show up.
(btw, the installation is on my laptop, using XP pro. Not supportet but generally works fine. I know ppl at Oracle have this working on XP so it should not be the issue).hi terje,
i just tested this on my 10.1.2 installation using IE6 and it works fine. so it seems not to be any general issue.
2 things i would check:
- does a java scrip error occur on the page when you add/edit a text item. you see this in the left lower corner of the browser.
- check the log files on the application server mid-tier.
- but before starting debugging i would go to another pc and try to access your portal from there. this will show you if your client machine is the problem or if the portal installation is the problem.
regards,
christian -
Saving the text in text editor changes text line format
In my program I have an output witha text editor box where
we type in text and save , and if we want to print it it prints it out
on a smartform. When I type in a text on the text editor box for example :
"This will include a policy and best practice for
what files can be stored on the server and where
they should reside. The policy will include
required ownership of each folder and required
authorizations for access to folders. Also
included in the policy will be a section describing
best practices on the file and folder naming
conventions. Anew file struicture of the drive that
better aligns with the business. An drive with only
four folders at the root level also will be de"
After I type in this text in teh text editor and try saving it
, it save sthe text but shows up with lots of gaps like below.
"This will include a policy and best practice for
what files can be stored on the server and
where
they should reside. The policy will include
required ownership of each folder and
required
authorizations for access to folders. Also
included in the policy will be a section
describing
best practices on the file and folder naming
conventions. Anew file struicture of the drive
that
better aligns with the business. An drive with
only
four folders at the root level also will be de"
I am not preety sure why on saving teh typed text it chnages to this format.
I would like to have my program save it as is typed. Is this possible to do so
and how?
Thanks.Hi Aarav,
Check the internal table used to store the text is having line length 100. Change that to 200 or more . You can see the difference . If still the problem persists, enter each line in the text editor and conclude each line with a carriage return( ENTER )
key press.
Hope this will help you.
Regards,
Smart Varghese -
Idoc is recieved as xml format instead of text format
hi i am new to XI , I am right now i am trying with Idoc to file scenario
i am sending idoc from an R/3 system and i am receiving it as file in another R/3 system. In accordance to that i have designed & configured all settings, But when i am sending idoc thru my communication channel i am able view a '" *.txt " file with all my necessary details in xml format instead of text format.
desin details
my source and target fields are
FLCUSTOMER_CREATEFROMDATA idoc to the file which as the only few important fields of idoc.
configuration details
in communication cahnnel :
adapter type : file
message protocol: file
processing parameters:
constructution mode : create
file type : binary
advance mode
row.fieldNames : with its fields seperated buy comma
row.fieldSeparator : ,
row.endSeparator : 'nl'
i stuked up with this level for the past 10 days ur valuble suggestion will help me lot to reach my target
Regards
saravanakumar P.K.You have selected the wrong message protocol: to get an file not XML you should select File Content converion as message protocol
change it to folowing
configuration details
in communication cahnnel :
adapter type : file
message protocol: file content conversion
processing parameters:
constructution mode : create
file type : binary
advance mode
row.fieldNames : with its fields seperated buy comma dnt use this
row.fieldSeparator : ,
row.endSeparator : 'nl'
specify only field sepratator and endseparator dnt have to specify fielnames for receiver adapter in contant conversion.
Maybe you are looking for
-
"iTunes could not connect to the Music Store" Error Message
Hello all, I finally got my script running correctly and I can see the front page of my iTunesU site(Yay!). But I am getting an irritating error message, and what is unusual are the circumstances under which I see the error message and the circumstan
-
Hi, This is the only USER who is facing above issue. But when he hold CTRL key and click on the file. It works fine. We are using IE 8 32 bit. Please note it works fine in IE 8 64 bit. Could you please advise why it happens? Is this something share
-
Debug Appication in client pc- Fatal Error
Hello every one I need to debug my exe which i have installed in my client pc While building exe i enable the option enabled debugging In my pc i entered into operate-->connect to remote panel then i entered the ip address on my client pc and port
-
Earlier Versions of JDeveloper?
Does anyone know where I could get an earlier version of JDeveloper? Possibly 1.5? Thanks Jesse null
-
Forgot admin. password, using install disk- STILL CAN'T RESTART IT :[
I'm so frustrated. I forgot my administrator password, so I read up that I use my Mac OS X Install Disc 1 At first, I wasn't able to restart it because it said I needed a password, so then I did manual restart while holding the C key and that worked.