473,625 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ignorable Whitespace

Hi there,

A class in Xerces J-API (Java) called TextImpl contains a property that
returns whether the text is ignorable whitespace
(http://xml.apache.org/xerces-j/apiDo...eWhitespace()). ;

I guess when they refer to "ignorable whitespace" in Java we may interpret
that as an "insignific ant whitespace" in .NET. Am I correct to say that?

So, I need to manually convert some Java code to C#, and the following
excerpt shows the converted code, except for the line marked with
"//<--****". I have spent a lot of time trying to find out how that
if-statement could be converted to C# with no success, mostly because I am a
beginner in XML.

The excerpt of code is this:

XmlNodeList children = node.ChildNodes ;
string svalue;
if ( children != null )
{
//we want to delete ignorable whitespace from
//the dom tree
for ( int z = 0; z < children.Count; z++ )
{
if ( children.Item(z ) is XmlText) // instanceof TextImpl )
{
svalue = children.Item(z ).Value.Trim();

if ( (children.Item( z)).isIgnorable Whitespace() ) // <--****
{
node.RemoveChil d( children.Item(z ) );
z--;
}
}
}
}

Three questions:
1. Can we say that XmlText is the counterpart of Java Xerces' TextImpl
(reference:
http://xml.apache.org/xerces-j/apiDo.../TextImpl.html) ?

2. Is it correct and safe to say that the term "insignific ant whitespace"
referred in MSDN Library is the same as saying "ignorable whitespace" in Java?

3. How would the code line marked with "//<--****" in above's excerpt be
coded in C#?

Many thanks in advance.

--
Carlitos
Nov 12 '05 #1
2 2021
Carlitos wrote:
A class in Xerces J-API (Java) called TextImpl contains a property that
returns whether the text is ignorable whitespace
(http://xml.apache.org/xerces-j/apiDo...eWhitespace()). ;

I guess when they refer to "ignorable whitespace" in Java we may interpret
that as an "insignific ant whitespace" in .NET. Am I correct to say that?

So, I need to manually convert some Java code to C#, and the following
excerpt shows the converted code, except for the line marked with
"//<--****". I have spent a lot of time trying to find out how that
if-statement could be converted to C# with no success, mostly because I am a
beginner in XML.

The excerpt of code is this:

XmlNodeList children = node.ChildNodes ;
string svalue;
if ( children != null )
{
//we want to delete ignorable whitespace from
//the dom tree
for ( int z = 0; z < children.Count; z++ )
{
if ( children.Item(z ) is XmlText) // instanceof TextImpl )
{
svalue = children.Item(z ).Value.Trim();

if ( (children.Item( z)).isIgnorable Whitespace() ) // <--****
{
node.RemoveChil d( children.Item(z ) );
z--;
}
}
}
}

Three questions:
1. Can we say that XmlText is the counterpart of Java Xerces' TextImpl
(reference:
http://xml.apache.org/xerces-j/apiDo.../TextImpl.html) ?
Yes, that's correct.
2. Is it correct and safe to say that the term "insignific ant whitespace"
referred in MSDN Library is the same as saying "ignorable whitespace" in Java?
Yes, it's safe.
3. How would the code line marked with "//<--****" in above's excerpt be
coded in C#?


I believe it would be
if ( children.Item(z )).NodeType == XmlNodeType.Whi tespace )

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2
Many many mmmmmmany thanks, Oleg.

C
"Oleg Tkachenko [MVP]" wrote:
Carlitos wrote:
A class in Xerces J-API (Java) called TextImpl contains a property that
returns whether the text is ignorable whitespace
(http://xml.apache.org/xerces-j/apiDo...eWhitespace()). ;

I guess when they refer to "ignorable whitespace" in Java we may interpret
that as an "insignific ant whitespace" in .NET. Am I correct to say that?

So, I need to manually convert some Java code to C#, and the following
excerpt shows the converted code, except for the line marked with
"//<--****". I have spent a lot of time trying to find out how that
if-statement could be converted to C# with no success, mostly because I am a
beginner in XML.

The excerpt of code is this:

XmlNodeList children = node.ChildNodes ;
string svalue;
if ( children != null )
{
//we want to delete ignorable whitespace from
//the dom tree
for ( int z = 0; z < children.Count; z++ )
{
if ( children.Item(z ) is XmlText) // instanceof TextImpl )
{
svalue = children.Item(z ).Value.Trim();

if ( (children.Item( z)).isIgnorable Whitespace() ) // <--****
{
node.RemoveChil d( children.Item(z ) );
z--;
}
}
}
}

Three questions:
1. Can we say that XmlText is the counterpart of Java Xerces' TextImpl
(reference:
http://xml.apache.org/xerces-j/apiDo.../TextImpl.html) ?


Yes, that's correct.
2. Is it correct and safe to say that the term "insignific ant whitespace"
referred in MSDN Library is the same as saying "ignorable whitespace" in Java?


Yes, it's safe.
3. How would the code line marked with "//<--****" in above's excerpt be
coded in C#?


I believe it would be
if ( children.Item(z )).NodeType == XmlNodeType.Whi tespace )

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #3

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

Similar topics

0
1986
by: haughki | last post by:
apologies for asking this. it must have been answered before. i have really tried to find the answer elsewhere. a simple question: i'd like to remove all ignorable whitespace from my minidom representation. it make the DOM much cleaner (for me). i've resorted to parsing first with Sax2 and using StripXml to deal with the whitespace. why not stick with the Sax2 DOM you ask? legacy code all uses the minidom, and they're not *quite*...
0
1403
by: Manuel Collado | last post by:
Perhaps I've missed something obvious, but after reading the docs and doing some Google search I can't find how to detect ignorable whitespace with the Expat parser. Could somebody enlighten me? Thanks, -- To reply by e-mail, please remove the extra dot in the given address: m.collado -> mcollado
2
2148
by: Wolfgang Jeltsch | last post by:
Hello, it is often convenient to insert whitespace into an XML document in order to format it nicely. For example, take this snippet of a notional DocBook XML document: <para> This is a longer paragraph. With <wordasword>longer</wordasword> I mean that it contains more than one sentence.
2
1940
by: Carlitos | last post by:
Hi there, A class in Xerces J-API (Java) called TextImpl contains a property that returns whether the text is ignorable whitespace (http://xml.apache.org/xerces-j/apiDocs/org/apache/xerces/dom/TextImpl.html#isIgnorableWhitespace()). I guess when they refer to "ignorable whitespace" in Java we may interpret that as an "insignificant whitespace" in .NET. Am I correct to say that? So, I need to manually convert some Java code to C#,...
0
2239
by: Shan Plourde | last post by:
Hi everyone, I have been using various regular expressions with the ASP.NET RegularExpressionValidator for quite some time. In general it works very well. One of the common regex's that I use follows: ValidationExpression = "^\d{0,3}(\.\d{0,4})?$" The purpose of this one is to validate that numeric values input follow the syntax 999.9999. This works well. But, one thing that I have never tested previously (which has now been uncovered...
3
2619
by: David Pratt | last post by:
Hi. I am splitting a string on a non whitespace character. One or more whitespace characters can be returned as items in the list. I do not want the items in the list that are only whitespace (can be one or more characters of whitespace) and plan to use string.strip on those items that are not only whitespace (to remove any whitespace from front or back of items). What kind of efficient test can I use to obtain only list items returned...
56
3531
by: infidel | last post by:
Where are they-who-hate-us-for-our-whitespace? Are "they" really that stupid/petty? Are "they" really out there at all? "They" almost sound like a mythical caste of tasteless heathens that "we" have invented. It just sounds like so much trivial nitpickery that it's hard to believe it's as common as we've come to believe.
9
2553
by: amattie | last post by:
Does anyone have any idea on how I can strip the extra whitespace in the XML that shows up when I receive a response from an ASP.NET 2.0 webservice? This has been discussed before, but no one has ever come up with a good answer to what seems like such a common question. ...
13
27950
by: Chaim Krause | last post by:
I am unable to figure out why the first two statements work as I expect them to and the next two do not. Namely, the first two spit the sentence into its component words, while the latter two return the whole sentence entact. import string from string import whitespace mytext = "The quick brown fox jumped over the lazy dog.\n" print mytext.split()
0
8253
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
8189
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
8692
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
6116
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
5570
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
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
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.