Link to home
Start Free TrialLog in
Avatar of skhorshid
skhorshid

asked on

MSXML4 - schemas

I am trying validate an XML file using MSXML4

I have a schema (not developed by me )
which is written in w3c format.

I get the following error when I try to add the schema
into the XMLSchemaCache.

Undeclared XSD type : '{http://www.w3.org/2001/XMLSchema}anyType'.

does MSXML4 does not support 'anyType' as a base in a restriction tag.

If this is true how would I rewrite the my XML to replace

<restriction base="xsd:anytype">
</restriction>

Here is an example: I think the person who wrote this only wanted to allow attribute vales and no element content.

<xsd:complexType name="DateType">
     <xsd:complexContent>
          <xsd:restriction base="xsd:anyType">
               <xsd:attribute name="type" use="required">
                    <xsd:simpleType>
                         <xsd:restriction base="xsd:token">
                                                <xsd:enumeration value="Receipt of tenders"/>
                                                <xsd:enumeration value="Base"/>
                                                <xsd:enumeration value="Acceptance of tender"/>
                                                <xsd:enumeration value="Possession of site"/>
                                                <xsd:enumeration value="Analysis last modified"/>
                         </xsd:restriction>
                    </xsd:simpleType>
               </xsd:attribute>
               <xsd:attribute name="ymdDate" type="xsd:date"/>
               <xsd:attribute name="ymDate" type="xsd:gYearMonth"/>
          </xsd:restriction>
     </xsd:complexContent>
</xsd:complexType>

Avatar of edmund_mitchell
edmund_mitchell

Hello skhorshid

What you are trying to do seems completely legal.
Assuming that your namespace is correct, and that the rest of your schema is OK, you have probably stumbled upon a bug, or a feature not yet implemented.
All I can suggest is that since the parent is a complexContent element, make your base the name of a complexType, even if you have to create one.
Then, send your Schema to MS, and see if they can reproduce the problem.

HTH

Edmund
Avatar of skhorshid

ASKER

I am not that sure if my name space is correct and I still cant add the schema to XMLSchemaCache.

<?xml version="1.0" ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema">

The error I am getting now is

Undeclared XSD type : '{http://www.w3.org/2001/XMLSchema}sfcaType'.


sfcaType occurs here


<complexType name="ElementSetType">
     <sequence>
                <element name="Element" type="ElementType" minOccurs="1" maxOccurs="unbounded"/>
        </sequence>
     <attribute name="sfca" type="sfcaType" default="BCIS 1973"/>
        <attribute name="level" type="levelType" default="Element"/>
        <attribute name="basis" type="basisType" default="Tender"/>
</complexType>


<simpleType name="sfcaType">
     <restriction base="token">
                <enumeration value="BCIS 1973"/>
                <enumeration value="Uniclass 1999"/>
     </restriction>
</simpleType>

<simpleType name="levelType">
     <restriction base="token">
                <enumeration value="Element"/>
                <enumeration value="Group element"/>
                <enumeration value="Total building"/>
     </restriction>
</simpleType>

<simpleType name="basisType">
     <restriction base="token">
                <enumeration value="Tender"/>
                <enumeration value="Final account"/>
     </restriction>
</simpleType>
I fixed that one, i think

Can you give me an example of how I would replace anyType in the example below knowing that all I want to do is restrict occurances of the date element(that uses datetype) to only to attribute content.


<xsd:complexType name="DateType">
    <xsd:complexContent>
         <xsd:restriction base="xsd:anyType">
              <xsd:attribute name="type" use="required">
                   <xsd:simpleType>
                        <xsd:restriction base="xsd:token">
                                               <xsd:enumeration value="Receipt of tenders"/>
                                               <xsd:enumeration value="Base"/>
                                               <xsd:enumeration value="Acceptance of tender"/>
                                               <xsd:enumeration value="Possession of site"/>
                                               <xsd:enumeration value="Analysis last modified"/>
                        </xsd:restriction>
                   </xsd:simpleType>
              </xsd:attribute>
              <xsd:attribute name="ymdDate" type="xsd:date"/>
              <xsd:attribute name="ymDate" type="xsd:gYearMonth"/>
         </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>
Hello skhorshid
In your examples, you're switching back and forth between schema as the default namespace (no prefix), and using xsd: as a prefix.  Just a heads-up.
You are declaring your DateType using the verbose form of the declaration.  There is another way, more compact, that does the exact same thing, and it avoids explicity using the anyType restriction base.  This compact syntax works because a complex type defined without any simpleContent or complexContent is interpreted as shorthand for complex content that restricts anyType, so maybe we can sneak it in:

<xsd:element name="date">
 <xsd:complexType>
  <xsd:attribute name="type" use="required" type="skhorshidType"/>
  <xsd:attribute name="currency" type="xsd:string"/>
  <xsd:attribute name="value"    type="xsd:decimal"/>
 </xsd:complexType>
</xsd:element>

and then we'll define the skhorshidType outside the date element to keep things simple:

 <xsd:simpleType name="skhorshidType">
  <xsd:restriction base="xsd:token">
   <xsd:enumeration value="Receipt of tenders"/>
   <xsd:enumeration value="Base"/>
   <xsd:enumeration value="Acceptance of tender"/>
   <xsd:enumeration value="Posession of site"/>  
   <xsd:enumeration value="Analysis last modified"/>
  </xsd:restriction>
 </xsd:simpleType>

This is just another way of doing the same thing you're currently trying to do, but hopefully it'll go through.
It's really weird that MSXML is giving you problems with anyType, it makes me wonder if there isn't some other problem in your Schema.
Anyways, give this a try.

Edmund
testing
Thanks Edmund.  My schema is aparently valid !
 
I have another problem now , I keep getting the error message

Line:3Position:26 Element content is invalid according to the DTD/Schema.
Expecting: Analysis.
 <Analysis currency="GBP">

I tried to paste the xml and schema in the last few messages. Can I email them to you ?

Sure.  My email is in my profile - I'll keep an eye out.

Edmund
Thanks Edmund.  My schema is aparently valid !
 
I have another problem now , I keep getting the error message

Line:3Position:26 Element content is invalid according to the DTD/Schema.
Expecting: Analysis.
 <Analysis currency="GBP">

I tried to paste the xml and schema in the last few messages. Can I email them to you ?

sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
ASKER CERTIFIED SOLUTION
Avatar of edmund_mitchell
edmund_mitchell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial