Hello
I need to validate xml files against dtd files, however the xml files I will
receive will not have the correct path to the dtd on my end. The declaration
in the xml is not qualified, it's just the dtd filename, so I figure I can
always copy the xml file to the same directory as the dtd then read/validate
the xml, however this is not an optimal solution.
Can anyone tell me if it is possible to explicitly define the path to the
dtd file when validating? I am currently using the XMLValidatingReader.
Thanks in advance
Jon 5 3759
HI Jon,
Indeed, you can use a pre-set path. See the example below:
public class Class1
{
static void Main()
{
XmlTextReader reader = new XmlTextReader("test.xml");
XmlValidatingReader valReader = new XmlValidatingReader(reader);
valReader.ValidationEventHandler += new ValidationEventHandler
(OnValidationError);
while (valReader.Read())
{
}
}
private static void OnValidationError(object sender, ValidationEventArgs
e)
{
Console.WriteLine(e.Message);
}
}
"Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message
news:40***********************@news.twtelecom.net. .. Hello
I need to validate xml files against dtd files, however the xml files I
will receive will not have the correct path to the dtd on my end. The
declaration in the xml is not qualified, it's just the dtd filename, so I figure I can always copy the xml file to the same directory as the dtd then
read/validate the xml, however this is not an optimal solution.
Can anyone tell me if it is possible to explicitly define the path to the dtd file when validating? I am currently using the XMLValidatingReader.
Thanks in advance
Jon
Let me give a little more detail. This is a portion of my xml file:
--snip--
<?xml version = "1.0" encoding = "us-ascii"?>
<!DOCTYPE PurchaseOrder
PUBLIC "-//asds//DTD PO//EN"
"PO.dtd">
--snip--
Notice that the DOCTYPE declaration references PO.dtd. I need to specify the
location of the dtd, as it will most likely not be in the same location as
the source xml file.
Jon
"Bennie Haelen" <be***********@jda.com> wrote in message
news:u8**************@TK2MSFTNGP10.phx.gbl... HI Jon,
Indeed, you can use a pre-set path. See the example below:
public class Class1 { static void Main() { XmlTextReader reader = new XmlTextReader("test.xml"); XmlValidatingReader valReader = new XmlValidatingReader(reader); valReader.ValidationEventHandler += new ValidationEventHandler (OnValidationError); while (valReader.Read()) { } }
private static void OnValidationError(object sender,
ValidationEventArgs e) { Console.WriteLine(e.Message); } } "Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message news:40***********************@news.twtelecom.net. .. Hello
I need to validate xml files against dtd files, however the xml files I will receive will not have the correct path to the dtd on my end. The declaration in the xml is not qualified, it's just the dtd filename, so I figure I
can always copy the xml file to the same directory as the dtd then read/validate the xml, however this is not an optimal solution.
Can anyone tell me if it is possible to explicitly define the path to
the dtd file when validating? I am currently using the XMLValidatingReader.
Thanks in advance
Jon
Hi Jon,
You should be able to specify either a URL, or a valid local file path (if
you have the DTD local, which is a lot faster anyway).
instead of "PO.DTD", so for example, you can have:
<!DOCTYPE PurchaseOrder PUBLIC "-//asds//DTD PO//EN"
"c:\MyDtds\PO.dtd">
Bennie Haelen
"Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message
news:40***********************@news.twtelecom.net. .. Let me give a little more detail. This is a portion of my xml file:
--snip--
<?xml version = "1.0" encoding = "us-ascii"?>
<!DOCTYPE PurchaseOrder PUBLIC "-//asds//DTD PO//EN" "PO.dtd">
--snip--
Notice that the DOCTYPE declaration references PO.dtd. I need to specify
the location of the dtd, as it will most likely not be in the same location as the source xml file.
Jon
"Bennie Haelen" <be***********@jda.com> wrote in message news:u8**************@TK2MSFTNGP10.phx.gbl... HI Jon,
Indeed, you can use a pre-set path. See the example below:
public class Class1 { static void Main() { XmlTextReader reader = new XmlTextReader("test.xml"); XmlValidatingReader valReader = new XmlValidatingReader(reader); valReader.ValidationEventHandler += new ValidationEventHandler (OnValidationError); while (valReader.Read()) { } }
private static void OnValidationError(object sender, ValidationEventArgs e) { Console.WriteLine(e.Message); } } "Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message news:40***********************@news.twtelecom.net. .. Hello
I need to validate xml files against dtd files, however the xml files
I will receive will not have the correct path to the dtd on my end. The declaration in the xml is not qualified, it's just the dtd filename, so I figure I can always copy the xml file to the same directory as the dtd then read/validate the xml, however this is not an optimal solution.
Can anyone tell me if it is possible to explicitly define the path to the dtd file when validating? I am currently using the
XMLValidatingReader. Thanks in advance
Jon
Hi Bennie
The xml files are created by a customers software, so I don't have the
option of editing the xml. They provided the dtd files and are requiring
that we validate incoming documents.
Can the path to the dtd be set programmatically in a validation object
somehow? or can the doctype be overridden? I haven't seen any examples of
this so I'm thinking I may be forced to just copy the xml to the same folder
as the dtd then read/validate.
Jon
<ha*****@bellsouth.net> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl... Hi Jon,
You should be able to specify either a URL, or a valid local file path (if you have the DTD local, which is a lot faster anyway). instead of "PO.DTD", so for example, you can have:
<!DOCTYPE PurchaseOrder PUBLIC "-//asds//DTD PO//EN" "c:\MyDtds\PO.dtd">
Bennie Haelen
"Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message news:40***********************@news.twtelecom.net. .. Let me give a little more detail. This is a portion of my xml file:
--snip--
<?xml version = "1.0" encoding = "us-ascii"?>
<!DOCTYPE PurchaseOrder PUBLIC "-//asds//DTD PO//EN" "PO.dtd">
--snip--
Notice that the DOCTYPE declaration references PO.dtd. I need to specify the location of the dtd, as it will most likely not be in the same location
as the source xml file.
Jon
"Bennie Haelen" <be***********@jda.com> wrote in message news:u8**************@TK2MSFTNGP10.phx.gbl... HI Jon,
Indeed, you can use a pre-set path. See the example below:
public class Class1 { static void Main() { XmlTextReader reader = new XmlTextReader("test.xml"); XmlValidatingReader valReader = new
XmlValidatingReader(reader); valReader.ValidationEventHandler += new ValidationEventHandler (OnValidationError); while (valReader.Read()) { } }
private static void OnValidationError(object sender, ValidationEventArgs e) { Console.WriteLine(e.Message); } } "Jon L. Lovesky" <jo**@willowrunfoods.com> wrote in message news:40***********************@news.twtelecom.net. .. > Hello > > I need to validate xml files against dtd files, however the xml
files I will > receive will not have the correct path to the dtd on my end. The declaration > in the xml is not qualified, it's just the dtd filename, so I figure
I can > always copy the xml file to the same directory as the dtd then read/validate > the xml, however this is not an optimal solution. > > Can anyone tell me if it is possible to explicitly define the path
to the > dtd file when validating? I am currently using the
XMLValidatingReader. > > Thanks in advance > > Jon > >
Jon L. Lovesky wrote: The xml files are created by a customers software, so I don't have the option of editing the xml. They provided the dtd files and are requiring that we validate incoming documents.
Can the path to the dtd be set programmatically in a validation object somehow? or can the doctype be overridden? I haven't seen any examples of this so I'm thinking I may be forced to just copy the xml to the same folder as the dtd then read/validate.
You can provide custom XmlResolver to XmlValidatingReader and resolve
PO.dtd to actual PO.dtd location in it.
--
Oleg Tkachenko [XML MVP, XmlInsider] http://blog.tkachenko.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Stefan Richter |
last post by:
Hi, after coding for days on stupid form validations -
Like:
strings (min / max length), numbers(min / max value), money(min / max
value), postcodes(min / max value), telefon numbers,
email...
|
by: rcb845 |
last post by:
Hi everybody Javascript specialist,
I am relatively new in Javascript world. I have a problem to solve and
I hope one of you can help me.
I am building a validation system, i.e. I want to...
|
by: Scott Meyers |
last post by:
I have a web site that, due to maintenance by several people, some of whom are
fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point
where I'm pretty sure it's suffering...
|
by: Sudip Chakraborty |
last post by:
Is there a way to see constraint validation errors while loading xml into a
DataSet ? I'm interested in the line number in the xml file which is causing
the error. I've enclosed the relevant stack...
|
by: eXavier |
last post by:
Hi,
I need to validate XML fragment against XSD schema. The main issue is that
xml fragment does not contain refrence to schema, but I want to force the
validation against the schema I have in...
|
by: Vlad |
last post by:
I have the following code:
I have a local copy of the DTD that I need to validate incoming XML
documents against.
The XML document has the <!DOCTYPE myname SYSTEM "myfile.dtd"> define.
When the...
|
by: paul_zaoldyeck |
last post by:
does anyone know how to validate an xml file against multiple defined
schema?
can you show me some examples?
i'm making here an xml reader..
thank you
|
by: Rik |
last post by:
Hello guys,
now that I'm that I'm working on my first major 'open' forms (with
uncontrolled users I mean, not a secure backend-interface), I'd like to add
a lot of possibilities to check wether...
|
by: lists |
last post by:
Hi all,
I am trying to validate an XML file against an XSD schema file within a
..NET C++ program, but the validation doesn't seem to be occuring.
My code is listed below. The validation...
|
by: hrishy |
last post by:
Hi
I am validating a xmlfile against a xsd (My.xsd) but i notice that the xsd has a include which includes another xsd (My1.xsd)
I have written a simple program that to validate this
from...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |