 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Pascal Donio Guest
|
Posted: Wed Feb 23, 2005 8:37 pm Post subject: Cannot validate an XML using an XSD |
|
|
Hi all,
I wrote a test web service that contains a DataModule with a TXMLDocument component. The vendor I am using is MSXML. I am running my test on both Win XP and also Win 2000. I exposed the following procedure to load the XML content in my web service:
function TWsTest.Test1(WS: WideString): WideString;
begin
with WsTestDataModule do
try
XMLDocument1.Active := False;
XMLDocument1.ParseOptions := XMLDocument1.ParseOptions +
[poResolveExternals, poValidateOnParse];
XMLDocument1.XML.Text := WS;
XMLDocument1.Active := True;
Result := XMLDocument1.XML.Text;
except
on E:Exception do
Result := Format('<Exception>%s</Exception>', [E.Message]);
end;
end;
This is the test XSD I am using:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:simpleType name="AmountType">
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Bonus">
<xs:complexType>
<xs:sequence>
<xs:element name="Amount" type="AmountType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
And here is the test XML I am using as well:
<?xml version="1.0" encoding="UTF-8"?>
<Bonus
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="..."> <Amount>2000.001111</Amount>
</Bonus>
Where "..." is the location of my XSD. Note that the Amount is wrong and does not conform to AmountType. Depending on the location value, I get these behaviors:
1) noNamespaceSchemaLocation="file:///C:/mypath/validate.xsd"
The XML is not validated and loads without problems. (The file does exist.)
2) noNamespaceSchemaLocation="C:mypathvalidate.xsd"
Same as #2.
3) noNamespaceSchemaLocation="http://mywebsite/validate.xsd"
I set up my machine as a web server using IIS. I dumped the XSD in the wwwroot dir and can view it using a browser. Yet the web service raises the error: "No Data is Available for the Requested Resource."
4) noNamespaceSchemaLocation="http://TotallyInvalidAddress"
Same as #2.
5) If I test case #3 again I get the same behavior as #4 (caching?).
Has anybody ever encountered this kind of problem(s)? Any suggestion would help.
TIA,
--Pascal
|
|
| Back to top |
|
 |
Pascal Donio Guest
|
Posted: Mon Feb 28, 2005 5:50 pm Post subject: Re: Cannot validate an XML using an XSD |
|
|
Figured out the problem. It was related to the msxml dll used. Insatlled msxml4 on the winnt machine and now it works like a charm.
--Pascal
|
|
| Back to top |
|
 |
Ashok Guest
|
Posted: Fri Apr 01, 2005 4:34 pm Post subject: Re: Cannot validate an XML using an XSD |
|
|
How do I am using after installing MSXML4 ?
What do I have to do in Delphi ?
My OLD MSXML.dll is still there.
One more quiestion, if my XML contains non-existance tag, would
validation against XSD fail?
Thanks,
Asjok
"Pascal Donio" <xmlproblem (AT) mailinator (DOT) com> wrote
| Quote: |
Figured out the problem. It was related to the msxml dll used. Insatlled
msxml4 on the winnt machine and now it works like a charm.
--Pascal
|
|
|
| Back to top |
|
 |
Ashok Guest
|
Posted: Fri Apr 01, 2005 4:35 pm Post subject: Re: Cannot validate an XML using an XSD |
|
|
How do I know that I am using after installing MSXML4 ?
What do I have to do in Delphi ?
My OLD MSXML.dll is still there.
One more quiestion, if my XML contains non-existance tag, would
validation against XSD fail?
Thanks,
Ashok
"Pascal Donio" <xmlproblem (AT) mailinator (DOT) com> wrote
| Quote: |
Figured out the problem. It was related to the msxml dll used. Insatlled
msxml4 on the winnt machine and now it works like a charm.
--Pascal
|
|
|
| Back to top |
|
 |
Stephane Grobety Guest
|
Posted: Wed May 11, 2005 1:45 pm Post subject: Re: Cannot validate an XML using an XSD |
|
|
| Quote: | One more quiestion, if my XML contains non-existance tag, would
validation against XSD fail?
|
It should fail to validate.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|