I want to reference an URL having character entities using C#/.NET on an XmlReader instance, for example this w3c entity set defining
and other chars.
If I were to accomplish it in pure XML it would something like this, or a variation:
<!ENTITY foo SYSTEM "http://example.org/myent.ent">
I'm actually reading fragments of XHTML source (containing named entities) and therefore need the XML 1.0/HTML 4 named Entity Sets defined by w3c to be defined/recognized.
(I suppose I'm asking how to programmatically reference them on-the-fly while setting up the XmlReader and its Settings for reading fragments; however I'm open to options).
Either way, if I don't include these named entities the reader will cough and produce .NET errors such as the following XmlException for
and other non-numeric entities:
Test 'Xml_Tester.Test_Reading' failed: System.Xml.XmlException : Reference to undeclared entity 'nbsp'. Line 6, position 393.
Note: I'm successfully referencing an XHTML Schema using the XmlReaderSettings.Schemas collection property, and assume there has to be an equally easy way to call in external entity references without modifying the XML source, but it evades me.
Etc:
I've come across the following significant info bits while searching for an answer -they're likely useful here ...
Support for entities
To use entities, authors have to use the DTD mechanism. See section 1.5 to use DTD and XML Schema together.
-- http://www.w3.org/TR/xhtml1-schema/#diffs
1.5. Using DTD and XML Schema together
DTD validation and XML Schema validation are not mutually exclusive. Sometimes authors might want to use some DTD features (e.g. entities) while taking advantage of the XML Schema validation.
-- http://www.w3.org/TR/xhtml1-schema/#together
Combining XML Documents with XInclude
External entities must be declared in a DTD or an internal subset. This opens a Pandora's Box full of implications, such as the fact that the document element must be named in Doctype declaration and that validating readers may require that the full content model of the document be defined in DTD among others.
-- http://msdn.microsoft.com/en-us/library/aa302291.aspx#xinc_topic1