473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XML reading issue....

I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateId</key>
<string>AFL9124395098</string>
...........................
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader try
to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself and
it's going to be alllright.
Is there a way I could skip over it?

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>
Aug 28 '06 #1
6 1482
"Lloyd Dupont" <net.galador@ldwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateId</key>
<string>AFL9124395098</string>
..........................
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader try
to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could define
your own XmlResolver derived class which processes the remote DTD in any way
you like.

John
Aug 28 '06 #2
Thanks John!

However that doesn't work, if I disable the DTD, I get an XmlException: "The
DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML reader
doesn't want to read the XML document because the DTD is not validated...

"John Saunders" <john.saunders at trizetto.comwrote in message
news:uP**************@TK2MSFTNGP03.phx.gbl...
"Lloyd Dupont" <net.galador@ldwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateId</key>
<string>AFL9124395098</string>
..........................
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?

I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John


Aug 28 '06 #3
Lloyd Dupont wrote:
Thanks John!

However that doesn't work, if I disable the DTD, I get an XmlException: "The
DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML reader
doesn't want to read the XML document because the DTD is not validated...
Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).

Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
"John Saunders" <john.saunders at trizetto.comwrote in message
news:uP**************@TK2MSFTNGP03.phx.gbl...
>"Lloyd Dupont" <net.galador@ldwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl. ..
>>I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateId</key>
<string>AFL9124395098</string>
..........................
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading myself
and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader to
null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John


Aug 28 '06 #4
>However that doesn't work, if I disable the DTD, I get an XmlException:
>"The DTD is deactivate, activate it this way..."

So I'm stuck between a rock and a hard place.
I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated...

Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with the
PList editor which puts that in. Every time they edit a file I will have to
go after them.....
>
Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
that's interesting! how do I do that?
I tryed to set my own XmlResolver but, unless I write a bug during my
experimentation, that didn't work... (I'm a bit suspicious though...)
///Peter
--
XML FAQ: http://xml.silmaril.ie/
>"John Saunders" <john.saunders at trizetto.comwrote in message
news:uP**************@TK2MSFTNGP03.phx.gbl...
>>"Lloyd Dupont" <net.galador@ldwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl.. .
I have some XML file like that:

===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>affiliateId</key>
<string>AFL9124395098</string>
..........................
===

Now when I'm reading them with XmlDocument or XmlTextReader the reader
try to connect to aple (because of <!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">)
and that causes exception when there is no network (and of course the
XmlTextReader or XmlDocument fail to read the text)

The problem is: I don't care about apple schema, I do the reading
myself and it's going to be alllright.
Is there a way I could skip over it?
I believe that if you set the XmlResolver property of the XmlTextReader
to null, it will ignore the remote DTD. If that doesn't do it, you could
define your own XmlResolver derived class which processes the remote DTD
in any way you like.

John

Aug 28 '06 #5
Lloyd Dupont wrote:
>>I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated...
[me]
>Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
[lloyd]
I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with the
PList editor which puts that in. Every time they edit a file I will have to
go after them...
OK, I thought this might be an automated process.

[me]
>Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
[lloyd]
that's interesting! how do I do that?
sed -e "s+http://www.apple.com+file:///some/directory+" old.xml >new.xml

This leaves you with output that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"/some/directory/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

All you need to do is make sure you have a directory in the relevant
place in your tree called /some/directory/DTDs, and in it a copy of the
PropertyList-1.0.dtd file (which you get from Apple; plus any ancillary
files it references).

Now when you edit/process the document, it will validate against the
local copy. You can replace /some/directory with whatever is suitable
for your system.

sed is available for Microsoft systems both with and without Cygwin
support, I believe.

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Aug 29 '06 #6
mmh....
thanks ;-)

"Peter Flynn" <pe********@m.silmaril.iewrote in message
news:4l************@individual.net...
Lloyd Dupont wrote:
>>>I don't want to valid the DTD because there is no network and the XML
reader doesn't want to read the XML document because the DTD is not
validated...
[me]
>>Just cut out the DocType Declaration before the file gets processed
(ie pass it through a filter of some kind, like sed).
[lloyd]
>I had avoid that if I could.
That makes it forgetfulness prone. Our Mac developer edit the fil with
the PList editor which puts that in. Every time they edit a file I will
have to go after them...

OK, I thought this might be an automated process.

[me]
>>Or filter it so that the SYSTEM Identifier resolves to a local file,
and keep a copy of the DTD at that filename.
[lloyd]
>that's interesting! how do I do that?

sed -e "s+http://www.apple.com+file:///some/directory+" old.xml >new.xml

This leaves you with output that starts like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"/some/directory/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

All you need to do is make sure you have a directory in the relevant place
in your tree called /some/directory/DTDs, and in it a copy of the
PropertyList-1.0.dtd file (which you get from Apple; plus any ancillary
files it references).

Now when you edit/process the document, it will validate against the
local copy. You can replace /some/directory with whatever is suitable for
your system.

sed is available for Microsoft systems both with and without Cygwin
support, I believe.

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Sep 1 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
4
by: Mark Stijnman | last post by:
A while ago I posted a question about how to get operator behave differently for reading and writing. I basically wanted to make a vector that can be queried about whether it is modified recently...
0
by: Webster | last post by:
Hello, I have a program that asynchronously reads data from a host. However, whenever I call the BeginRead function, the async reading "loop" never seems to terminate. Why doesn't the EndRead...
7
by: John Dann | last post by:
I'm trying to read some binary data from a file created by another program. I know the binary file format but can't change or control the format. The binary data is organised such that it should...
10
by: Johhny | last post by:
Hello All, I am working my way through learning python as a language. I am having some issues with something that looks right and does not work. I am trying to get myself more familure with...
2
by: RR | last post by:
I'm trying to read an xml file into a dataset just like I do in my windows application. DataSet.ReadXML("filename.xml"); But no matter how I have the string file name the application errors...
5
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I...
111
by: Tonio Cartonio | last post by:
I have to read characters from stdin and save them in a string. The problem is that I don't know how much characters will be read. Francesco -- ------------------------------------- ...
6
by: efrenba | last post by:
Hi, I came from delphi world and now I'm doing my first steps in C++. I'm using C++builder because its ide is like delphi although I'm trying to avoid the vcl. I need to insert new features...
9
by: Hal Vaughan | last post by:
I've done a fair amount of Googling for information on reading the serial port in C++ (and in Linux). Unfortunately, out of every 4 hits, 1 seems to be an unanswered question, 1 is someone saying,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.