Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Validating XML against Schema [Thread Next] Re: Validating XML against SchemaTo: NULL Date: 7/2/2004 12:13:00 PM Hello All,
My appologies for posting the wrong xml and schema files. I was trying
to make a temperorary xml and schema files, so that it would be easy
to post on the forum.
If you (any one else) want to take a look at the xml and schema files,
please mail me personally, I would send them to you. I don't want the
post to get too long.
Things that confuse me most:
Here I am using my actual XML header, so please don't get confused,
with my post. The actual header looks like this.
1) cisGlobals.xsd.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.talgov.com/cisGlobals"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:cisGlobals="http://www.talgov.com/cisGlobals"
elementFormDefault="unqualified">
2) accountInformationUpdate.xsd
<xs:schema elementFormDefault="unqualified"
attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cisGlobals="http://www.talgov.com/cisGlobals">
<xs:import namespace="http://www.talgov.com/cisGlobals"
schemaLocation="cisGlobals.xsd"/>
<xs:element name="AccountUpdate">
There is no default namespace defined in this schema file, but this is
importing from a schema file which has a target namespace. what would
be the namespace of this schema file.
3) cis.xml
<AccountUpdate xmlns:cisGlobals="http://www.talgov.com/cisGlobals"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.talgov.com/cisGlobals
accountInformationUpdate.xsd">
Here I am using the namespace of http://www.talgov.com/cisGlobals this
is the target namespace used in first schema file. How would the
AccountUpdate and rest of the tags would be referred as.
Thank you for all your help, and once again sorry for the confusion.
murali.
maddalimurali@y... (maddalimurali) wrote in message news:<d3ecf31.0407020556.1339748@p...>...
> Hello All,
>
> I am having trouble validating an XML files against its Schema file
> using .net System.XML class library and MSXML4, MSXML3 as well. Here
> is the sample how my xml file and schema file looks like.
>
> Schema file 1 : tmpGlobals.xsd.
> -----------------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace="http://www.temp.com/tmpGlobals"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:tmpGlobals="http://www.temp.com/tmpGlobals"
> elementFormDefault="unqualified">
> <xsd:simpleType name="phoneType">
> <xsd:restriction base="xsd:normalizedString">
> <xsd:pattern value="
> BUSN|CAMP|CELL|DORM|FAX|HOME|OPH1|OPH2|PGR1|PGR2|T
> ELX"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> <xsd:simpleType name="servicePointId">
> <xsd:restriction base="xsd:string">
> <xsd:pattern value="[0-9]{10}"/>
> </xsd:restriction>
> </xsd:simpleType>
>
> <xsd:complexType name="serviceAddress">
> <xsd:sequence>
> <xsd:element name="servicePoint" type="tmpGlobals:servicePointId"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:schema>
>
> -----------------------------------------------------------------------------
>
> Schema file 2 : account.xsd
> -----------------------------------------------------------------------------
> <xs:schema elementFormDefault="unqualified"
> attributeFormDefault="unqualified"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:tmpGlobals="http://www.temp.com/tmpGlobals">
> <xs:import namespace="http://www.temp.com/tmpGlobals"
> schemaLocation="tmpGlobals.xsd"/>
> <xs:element name="AccountUpdate">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="AccountInformation" maxOccurs="unbounded">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="phone" type="tmpGlobals:phoneType" minOccurs="0"
> maxOccurs="unbounded"/>
> <xs:element name="serviceAddress" type="tmpGlobals:serviceAddress"
> maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="lifeSupportServicePoint"
> type="tmpGlobals:servicePointId" minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> </xs:schema>
> -----------------------------------------------------------------------------
>
> And my XML file looks like. test01.xml
> -----------------------------------------------------------------------------
> <AccountUpdate xmlns:tmpGlobals="http://www.temp.com/tmpGlobals"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.temp.com/globals account.xsd">
> <AccountInformation>
> <accountId>1234567890</accountId>
> <phone>
> <phoneType>HOME</phoneType>
> </phone>
> <entityName>Scott, Brian</entityName>
> <serviceAddress>
> <servicePoint>1234567890</servicePoint>
> </serviceAddress>
> </AccountInformation>
> <lifeSupportServicePoint>2395932592</lifeSupportServicePoint>
> </AccountUpdate>
> -----------------------------------------------------------------------------
>
> Whenever I try to validate this file by loading it into
> XmlValidatingReader, but I keep getting error saying.
> "System.Xml.Schema.XmlSchemaException: The attribute targetNamespace
> does not match the designated namespace URI. "
>
> When I try to validate from Visual Studio .net environment I get the
> following error. "Visual Studio could not locate a schema for this
> document. Validation can only ensure this is a well formed XML
> document and cannot validate the data against a schema.
> "
>
> And when I try to use MSXML4, it would load the file fine, but it is
> not validating the xml file.
>
> I tried couple of ways by hard coding schema path, copying schema
> files and xml files in the same directories but none of those worked.
>
> However when I validate the same xml file in xml spy, it validates
> with out any errors. Is there any thing that I am missing over here.
>
> Any kind of help is greatly appreciated.
>
> Thank you.
> murali.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
