Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Internal Entity

Status
Not open for further replies.

Stonkers

Programmer
Oct 14, 2003
16
0
0
US
I'm sure my usage is incrorrect but can't find a good sample for using these. Here's what I'm trying:

<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>
<configuration>
<!DOCTYPE settings [
<!ENTITY WebPath &quot; ]>
...

and then later (in the same file) use:

<someTagOrOther>
<path=&quot;&WebPath;\myApp&quot;>
...

I'm getting an error that the DOCTYPE isn't in a DTD but don't understand. Can someone explain?

Thanks,
Eric
 
The DOCTYPE declaration must immediately follow the XML declaration. Your root element, <configuration>, cannot precede DOCTYPE as you show it. Also, just in case, you're only allowed one DOCTYPE declaration.

Good luck,
harebrain
 
That didn't work for me. Here's the specifics on how I tried to used it (in a web.config file for ASP.NET Web App):

<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?>
<!DOCTYPE settings [
<!ENTITY WebPath &quot;]>
<configuration>
<system.runtime.remoting>
<application>
<client>
<wellknown type=&quot;MyApp.MyLib.MyDLL,MyApp.MyLib&quot;url=&quot;&WebPath;/myFile.rem&quot; />
</client>
</application>
</system.runtime.remoting>
</configuration>

Any clue why this won't work for me?

Thanks,
Eric
 
Sorry, forgot to post the stack trace:

Stack Trace:

[RemotingException: .Config file C:\Config\Web.config can not be read successfully due to exception System.ApplicationException: Invalid XML in file C:\Config\Web.config near element </xml>. ---> System.Runtime.InteropServices.COMException (0xC00CE565): Exception from HRESULT: 0xC00CE565.
at System.IConfigHelper.Run(IConfigHandler factory, String fileName)
at System.ConfigTreeParser.Parse(String fileName, String configPath)
--- End of inner exception stack trace ---
at System.ConfigTreeParser.Parse(String fileName, String configPath)
at System.Runtime.Remoting.Activation.RemotingXmlConfigFileParser.ParseConfigFile(String filename)
at System.Runtime.Remoting.RemotingConfigHandler.LoadConfigurationFromXmlFile(String filename).]
System.Runtime.Remoting.RemotingConfigHandler.LoadConfigurationFromXmlFile(String filename) +104
System.Runtime.Remoting.RemotingConfiguration.Configure(String filename) +16
ProCard.Centre.Web.Global.Application_Start(Object sender, EventArgs e) +355



 
This:
Code:
<wellknown type=&quot;MyApp.MyLib.MyDLL,MyApp.MyLib&quot;url=&quot;&WebPath;/myFile.rem&quot; />
is not well-formed. Whitespace is required between the value of an attribute and the name of the following attribute. IOW, put a space between the &quot; and the url.

You might want to try testing your XML in IE to wring the bugs out before moving on to more difficult things.
 
There was a space, that's just a bad translation by me (i.e. changed the real values to generic one's because that's what my organization wants me to do - cut the spaces out to be sure the line wouldn't wrap...). The xml works well without the Entity involved. Looks like it's a .NET problem. I don't think it supports DOCTYPE. Thanks for trying though!
 
I don't think it supports DOCTYPE.

That would be a pretty brain-dead implementation: DTDs are part of the XML 1.0 spec. I think you have to consider something else. And I can't help you with .NET, sorry.
 
As you suggested, I opened it up in IE and it worked fine (substituted correctly and all). I'm putting a ticket in with microsoft. I'll post here if I get any answers for future .NET seekers... Thanks for your help!
 
OK, here's what I got back from Microsoft:

“While web.config is an XML file, what you’re proposing isn’t really possible. There are a couple of reasons you don’t want to do this too, the main one being that in v1.X we actually restart the entire application when the web.config file changes. We also aren’t using an XML parser to read the .config file. Due to the size/complexity of the file (not to mention the memory impact) we actually only read the file in chunks – so when you access a portion of web.config we scan the file for a reference to that location and then use an XML parser only on the section you are currently accessing (we then cache that in memory in a object/class format). In V2 “Whidbey” we’ll have programmatic APIs for accessing the file, but we still won’t support DTD.”

Thanks for all attempts to help me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top