Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 636
  • Last Modified:

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>

0
skhorshid
Asked:
skhorshid
  • 10
  • 4
1 Solution
 
edmund_mitchellCommented:
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
0
 
skhorshidAuthor Commented:
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>
0
 
skhorshidAuthor Commented:
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>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
edmund_mitchellCommented:
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
0
 
skhorshidAuthor Commented:
0
 
skhorshidAuthor Commented:
0
 
skhorshidAuthor Commented:
testing
0
 
skhorshidAuthor Commented:
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 ?

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

Edmund
0
 
skhorshidAuthor Commented:
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 ?

0
 
skhorshidAuthor Commented:
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
skhorshidAuthor Commented:
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
skhorshidAuthor Commented:
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
edmund_mitchellCommented:
Got the files - won't be able to look at them today, probably, but tomorrow for sure.
A quick glance had me wondering about the namespace of the Analysis element, or maybe the parent of the Analysis element - I don't remember - but it seemed like there might have been a namespace conflict - I'll check.

Edmund
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now