473,657 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to handle pre-formatted text

I've got some pre-formatted text and I'm not sure how to encode it in
my xml to preserve its formatting. Any help would be appreciated!

TIA,
David
Jun 27 '08 #1
5 2609
David Schwartz wrote:
I've got some pre-formatted text and I'm not sure how to encode it in
my xml to preserve its formatting. Any help would be appreciated!
How is the formatting currently recorded?

If by "pre-formatted" you mean it contains spaces and tabs and
line-breaks -- that's no problem; basic XML considers all of that
meaningful content and will retain it. Individual XML applications may
discard some of this whitespace, perhaps based on schema and perhaps
based simply on their understanding of how that particular kind of XML
document should be interpreted... but that's a matter of how the XML is
used, not what it contains.

Exception: Whitespace and line breaks in attribute values will be
normalized. See the XML Recommendation for details.

If a particular tool doesn't retain information you need, it may not be
the right tool for your tasks, or you may not be using it right. To take
a specific example: XHTML, when displayed by a browser, will be
processed as HTML was and most whitespace will be discarded unless it is
in element specifically designed or marked to retain the existing
formatting. But that's the browser's behavior, and conventions of the
use of the XHTML markup, not XML.

If by "pre-formatted" you mean something else, please clarify.
Jun 27 '08 #2
David Schwartz wrote:
I've got some pre-formatted text and I'm not sure how to encode it in
my xml to preserve its formatting. Any help would be appreciated!
It depends on the features provided by whatever schema/dtd you are using
(if any). Some (eg DocBook) provide markup specifically designed to
contain data that requires the preservation of linebreaks, for example.
Others (eg XHTML) provide a container (pre) but the recommendation about
how to handle it is in the spec, not the markup.

Without a schema/dtd, the only facility is a CDATA section within some
suitable element, but this is intended for the preservation of otherwise
parsable *markup* characters, not space-and-newline formatting, so you'd
need to specify or convey to anyone using it exactly what they should or
should not do with it.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Jun 27 '08 #3
As far as XML is concerned, CDATA sections are just an alternative to
character-by-character escaping -- in other words, they're just syntax,
not semantics. They won't change how whitespace is interpreted, and they
may not even be visible to applications and/or may not be preserved
through stages of XML processing. So that approach isn't worth pursuing.

If you want to preserve whitespace, you need an element that your
particular application code doesn't process by discarding whitespace. As
I said, this is an application issue, not an XML issue per se... though
XML can provide some hints that the application may or not respect, such
as the xml:space attribute.

See http://www.w3.org/TR/REC-xml/#sec-white-space
Jun 27 '08 #4
Thanks for the responses. The content is just some CSS style
definitions.

For some reason, pasting the formatted content into the tool I'm using
(Turbo XML) resulted in it being pretty messed up. Editing the content
in a normal text editor to ensure that everything's lined up properly
led to the desired result. Also, the changes seemed to be preserved
after going back into the xml editor.

FYI, I'm just placing content within the xml tag into <pre></preHTML
tags.

Thanks again for the input,
David
Jun 27 '08 #5
David Schwartz wrote:
For some reason, pasting the formatted content into the tool I'm using
(Turbo XML) resulted in it being pretty messed up.
That sounds like a question of how cut and paste are working with your
tools -- how much non-text data the cut is capturing, and how good Turbo
XML is at figuring out how to discard it and just take the plaintext
view. Contact its authors and ask them...
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
18527
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px solid; color:red;
8
3776
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
11
5074
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text. Spy++ gives that this window is called _Wwg. How we can get a handle to this window assuming that we do not know beforehand the name of the process,
1
1586
by: Umut Tezduyar | last post by:
Because of the fact that, handling events method ( IPostBackEventHandler.RaisePorstBackEvent method) is prior to OnPreRender method, i cannot handle the events of the controls that i am adding on the OnPreRender method. Is there a way for that. Can i manually tell asp.net page to check again if there is control that is post backing to the server. ex: Load IPostBackEventHandler.RaisePostBackEvent ( in this phase parameter is
39
7376
by: tydbowl | last post by:
I have a problem where the below code chunk causes handle leaks on some machines. The leak APPEARS to be handles to the registry key: HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap The below code runs on a timer running several times per second and after about 15-30 minutes or so, it runs out of handles and crashes IE. I found an article on msdn discussing how setting properties in this
23
3615
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a so-called pre-fix notation or algebraic notation. Algebraic notations have the concept of operators, meaning, symbols placed around arguments. In algebraic in-fix notation, different
6
2695
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My problem is how do I handle the "path" parameter in cookie. First, the sequence start at http://www.testServer1.com/TestApp/page1.htm, and a cookie is set at
6
2023
by: dieselmachine | last post by:
Hey, I've been searching for info on this for days now, but to no avail. I'm starting to think it's impossible, but anyway! I've coded a little virtual keyboard, which has two octaves worth of keys on it, and when the keyboard image is clicked, it uses the coordinates to determine what key was pressed, then some stuff happens that we needn't worry about. I want to make the keys play the appropriate note when clicked, and I can't figure...
8
2885
by: dmoore | last post by:
Hi folks, I've seen the following issue come up in multiple posts to this mailing list: I have a python program that spawns a child process with popen or popen2 or popen3 or popen2.popen2 etc. the child process is interactive: it asks for input then spits out some output, asks for more input then spits out some output. for example, consider the trivial child program:
0
2225
by: Sergei Shelukhin | last post by:
Hi. I am writing an app that updates a certain windows service that is had previously installed. It stops the service, rewrites the file, and starts it again. On some machines, however, even though the service is stopped, I am getting "being used by another process" error. I wonder if there's any pre-made class in .NET framework or some third-party component that would close the handle to this file from whichever process, or kill...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.