473,666 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unable to preserve whitespace

I am unable to preserve white space.

Here is my code:
public class xml {
public static void main(String[] args) {
try{
String jaxpPropertyNam e = "javax.xml.pars ers.SAXParserFa ctory";
if (System.getProp erty(jaxpProper tyName) == null) {
String apacheXercesPro pertyValue =
"org.apache.xer ces.jaxp.SAXPar serFactoryImpl" ;
System.setPrope rty(jaxpPropert yName,
apacheXercesPro pertyValue);
}
SAXParserFactor y factory = SAXParserFactor y.newInstance() ;
SAXParser parser = factory.newSAXP arser();
Reader reader=new StringReader("< ?xml version='1.0'
encoding='UTF-8'?><References ><Reference><Na me>RITA
MOYER</Name><Address>< Street>5001 OAKVIEW DRIVE </Street><City>Lo s
Angeles</City><State>OH</State><ZIP>4408 9</ZIP></Address><EMail> </EMail><Phone>44 09678038</Phone><Relation ship>MOTHER</Relationship></Reference><Refe rence><Name>TIN A
MASLINSKI</Name><Address>< Street>4902 MAPLE VIEW
DRIVE</Street><City>Lo s
Angeles</City><State>OH</State><ZIP>4408 9</ZIP></Address><EMail> </EMail><Phone>44 09675992</Phone><Relation ship>FRIEND</Relationship></Reference></References>");
InputSource is=new InputSource(rea der);
factory.setName spaceAware(true );
parser.parse(is , new PrintHandler()) ;
} catch(Exception e) {
e.printStackTra ce();
}
}
}

I want the parser to show for Name "Rita Moyer". It now shows "Rita"

Thanks for your help

May 18 '06 #1
1 1481
I strongly suspect PrintHandler (which you didn't show us) has the
standard SAX-beginner's problem of forgetting that text may be spread
over successive calls to characters(). See any good SAX tutorial for a
discussion of how to deal with that.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 19 '06 #2

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

Similar topics

5
2359
by: Terje Sæternes | last post by:
It seems that this script wont run, any idea what I have don wrong+ Code----- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript" type="text/javascript"> <!--
0
1565
by: serge | last post by:
I have an XML file with an XSD file. When i am reading the XML file and putting its content into a DataSet I notice that the field that has a single space character is being converted to a field with no space character. DataSet ds = new DataSet(); ds.ReadXmlSchema(Path.ChangeExtension(fileNameC , ".xsd")); ds.ReadXml(fileNameC, XmlReadMode.ReadSchema);
11
3205
by: Brian W | last post by:
Yet another editor problem To reproduce do the following 1) Open a Webform and switch to HTML edit mode 2) Enter the Following (include spaces) This is some text before <asp:hyperlink id="hl1" runat="server " navigateurl="http://www.microsoft.com">This is my link</asp:hyperlink> And this is my text after the Hyperlink
4
2555
by: Chris Bower | last post by:
Reposted from aspnet.buildingcontrols: Ok, I've got a bunch of derived controls that all have a property Rights of type Rights (Rights is an Enumerator). I wrote a custom TypeConverter so that I can use comma separated values in design-time. The TypeConverter works great in design-time. It converts to and from just fine... However, when I try to load any page in the site now I get the following error (Following the error is code for the...
5
6905
by: Paul | last post by:
Off the cuff, does anyone know if arraylist is more efficeint at adding items to an array than redim preserve? Paul <begin loop> Dim c As Integer = SomeArray.GetUpperBound(0) + 1 ReDim Preserve SomeArray(c) SomeArray(c) = SomeObject <end loop>
6
1504
by: Mark | last post by:
In a specification I'm designing, I'd like to specify that the order of Names (IDs) in an attribute value of datatype IDREFS is significant. My question is if most real-world XML parsers preserve the order of IDs in IDREFS? If most don't, then specifying the significance of order is problematic. (As far as I can tell, the XML 1.0 spec is silent on this topic.)
2
5070
by: daftspaniel | last post by:
Hi Folks, I am trying to scan the lines in the string text: lines = text.split('\n') seemed to do the job but has the side effect of stripping the whitespace. As I am reading Python source in this text and checking identation this is a bit annoying :-) How can I stop this happening? Doesn't look like an option from the
1
3398
by: www.douglassdavis.com | last post by:
it seems every time i pass some text through an applet parameter, say: .... <PARAM name="mytext" value=' This is a test '> ....
0
2943
by: forgedascendant | last post by:
Good day everyone, I am new to this site so please forgive me if this post isn't completly correct. For the past 2 weeks I have been beating my head against the wall trying to figure out what is wrong with the macro I created. The problem I am experiancing is that the range I am trying to put together does not seem to be working for some reason. My entire code is as follows: Sub Proto1() ' ' Proto1 Macro ' Macro recorded 8/30/2007...
0
8445
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8871
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...
1
8551
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,...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
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();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.