By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

Ignorable Whitespace

P: n/a
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 "insignificant 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)).isIgnorableWhitespace() ) // <--****
{
node.RemoveChild( 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 "insignificant 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
Share this Question
Share on Google+
2 Replies


P: n/a
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 "insignificant 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)).isIgnorableWhitespace() ) // <--****
{
node.RemoveChild( 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 "insignificant 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.Whitespace )

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

P: n/a
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 "insignificant 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)).isIgnorableWhitespace() ) // <--****
{
node.RemoveChild( 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 "insignificant 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.Whitespace )

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

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.