Re: NSXMLElement children doesn't return whitespace text nodes

2011-03-04 Thread Heath Borders
>From the Tree-Based XML Programming Guide:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/CreatingXMLDoc.html#//apple_ref/doc/uid/TP40001255-BCIGHBDI

Preservation. The enum constants beginning with NSXMLNodePreserve
support document fidelity. They allow you to ensure that aspects of
the string XML input—for instance, quoting style of attribute values,
CDATA sections, attribute and namespace order—remain the same when XML
text is written out from the NSXMLDocument object. If you do not
specify a preservation option for an aspect, NSXMLDocument handles it
in a predetermined manner. For example, when NSXMLDocument reads in
and parses an XML document, it normally strips white-space characters
used in formatting (including tabs and carriage returns); however, if
you specify NSXMLNodePreserveWhitespace these characters are kept
hidden in the internal representation of the XML document. (“Hidden”
means the white-space characters are retained for the output of the
document, but are not visible within the tree representation.) Note
that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option.

Notice the last sentence:

Note that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option.

If my text node has non-whitespace in it, it gets recognized as a text
node, and whitespace is preserved in the stringValue:

A foo. a space on either side A
bar.

NSXMLElement *myTextElement = ... // get myText element somehow

[myTextElement stringValue]; // returns " a space on either side "

However:

A foo. A bar.

NSXMLElement *myTextElement = ... // get myText element somehow

[myTextElement stringValue]; // returns "" (empty)

This seems inconsistent with

"Note that white space in text nodes is always preserved, and is not
affected by the NSXMLNodePreserveWhitespace option."

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Fri, Mar 4, 2011 at 9:40 AM, Heath Borders  wrote:
> That worked!
>
> Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML
> and found my answer, as well:
>
> Changes malformed XML into valid XML during processing of the document.
> It also eliminates “pretty-printing” formatting, such as leading tab
> characters. However, it respects the xmlns:space="preserve" attribute.
> (Input)
> Available in Mac OS X v10.4 and later.
> Declared in NSXMLNodeOptions.h.
>
> -Heath Borders
> heath.bord...@gmail.com
> Twitter: heathborders
> http://heath-tech.blogspot.com
>
>
>
> On Thu, Mar 3, 2011 at 10:33 PM, Gideon King  wrote:
>> I recall that I had problems with that too, and IIRC, the 
>> NSXMLNodePreserveWhitespace didn't seem to work, but right now I have 
>> xml:space="preserve" in the XML and parse it with just the 
>> NSXMLDocumentTidyXML option, and that works. I believe I just went through 
>> all the combinations and permutations until I found that magic combination, 
>> and have just stuck with it.
>>
>> HTH
>>
>> Regards
>>
>> Gideon
>> On 04/03/2011, at 3:02 AM, Heath Borders wrote:
>>
>>> I have the following xml:
>>>
>>> A foo. A bar.
>>>
>>> Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?
>>>
>>> I've also tried changing my document thusly:
>>>
>>> A foo. A bar.
>>>
>>> I specify
>>>
>>> NSXMLNodePreserveWhitespace
>>>
>>> as my option to NSXMLDocument's
>>>
>>> initWithXMLString:options:error:
>>>
>>> selector.
>>>
>>> Thanks!
>>>
>>
>>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLElement children doesn't return whitespace text nodes

2011-03-04 Thread Heath Borders
That worked!

Embarrassingly, I looked at the documentation for NSXMLDocumentTidyXML
and found my answer, as well:

Changes malformed XML into valid XML during processing of the document.
It also eliminates “pretty-printing” formatting, such as leading tab
characters. However, it respects the xmlns:space="preserve" attribute.
(Input)
Available in Mac OS X v10.4 and later.
Declared in NSXMLNodeOptions.h.

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com



On Thu, Mar 3, 2011 at 10:33 PM, Gideon King  wrote:
> I recall that I had problems with that too, and IIRC, the 
> NSXMLNodePreserveWhitespace didn't seem to work, but right now I have 
> xml:space="preserve" in the XML and parse it with just the 
> NSXMLDocumentTidyXML option, and that works. I believe I just went through 
> all the combinations and permutations until I found that magic combination, 
> and have just stuck with it.
>
> HTH
>
> Regards
>
> Gideon
> On 04/03/2011, at 3:02 AM, Heath Borders wrote:
>
>> I have the following xml:
>>
>> A foo. A bar.
>>
>> Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?
>>
>> I've also tried changing my document thusly:
>>
>> A foo. A bar.
>>
>> I specify
>>
>> NSXMLNodePreserveWhitespace
>>
>> as my option to NSXMLDocument's
>>
>> initWithXMLString:options:error:
>>
>> selector.
>>
>> Thanks!
>>
>
>
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSXMLElement children doesn't return whitespace text nodes

2011-03-03 Thread Gideon King
I recall that I had problems with that too, and IIRC, the 
NSXMLNodePreserveWhitespace didn't seem to work, but right now I have 
xml:space="preserve" in the XML and parse it with just the NSXMLDocumentTidyXML 
option, and that works. I believe I just went through all the combinations and 
permutations until I found that magic combination, and have just stuck with it. 

HTH

Regards

Gideon
On 04/03/2011, at 3:02 AM, Heath Borders wrote:

> I have the following xml:
> 
> A foo. A bar.
> 
> Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?
> 
> I've also tried changing my document thusly:
> 
> A foo. A bar.
> 
> I specify
> 
> NSXMLNodePreserveWhitespace
> 
> as my option to NSXMLDocument's
> 
> initWithXMLString:options:error:
> 
> selector.
> 
> Thanks!
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSXMLElement children doesn't return whitespace text nodes

2011-03-03 Thread Heath Borders
I have the following xml:

A foo. A bar.

Is there a way to access the whitespace-only NSXMLTextKind NSXMLNode?

I've also tried changing my document thusly:

A foo. A bar.

I specify

NSXMLNodePreserveWhitespace

as my option to NSXMLDocument's

initWithXMLString:options:error:

selector.

Thanks!

-Heath Borders
heath.bord...@gmail.com
Twitter: heathborders
http://heath-tech.blogspot.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com