Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


XPathDocument and significant whitespace

From: "Michael Liu" <practicalvb@-------.--->
To: NULL
Date: 12/4/2005 4:35:00 AM
Why doesn't XPathDocument(validatingReader, XmlSpace.Default) preserve 
*all* the significant whitespace returned by the specified 
XmlValidatingReader (.NET Framework 1.1)? For example:

<!DOCTYPE p [
<!ELEMENT p (#PCDATA | b | i)*>
<!ELEMENT b (#PCDATA)>
<!ELEMENT i (#PCDATA)>
]>
<p>Here is <b>bold</b> <i>italic</i> text.</p>

The DTD says the <p> element contains mixed content, so when 
XmlValidatingReader reads this document, the XmlNodeType of the space 
between "</b>" and "<i>" is XmlNodeType.SignificantWhitespace. But the 
space is discarded by XPathDocument -- its private ReadChildNodes method 
treats significant whitespace as regular whitespace (which is then 
discarded) if the reader's XmlSpace property is anything but 
XmlSpace.Preserve.

Why does XPathDocument make this extra check for xml:space="preserve"?

(Since I don't want to put xml:space attributes all over the place in my 
documents, I'm going to pass XmlSpace.Preserve as the second argument to 
the XPathDocument constructor instead of XmlSpace.Default. But I'd still 
like to understand this behavior.)

Michael 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent