Solved

MSXML4 - schemas

Posted on 2001-09-05
14
623 Views
Last Modified: 2013-11-19
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
Comment
Question by:skhorshid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 4
14 Comments
 
LVL 4

Expert Comment

by:edmund_mitchell
ID: 6458136
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
 
LVL 2

Author Comment

by:skhorshid
ID: 6460146
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
 
LVL 2

Author Comment

by:skhorshid
ID: 6460263
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 4

Expert Comment

by:edmund_mitchell
ID: 6460542
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
 
LVL 2

Author Comment

by:skhorshid
ID: 6461400
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6461429
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6461442
testing
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6461449
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
 
LVL 4

Expert Comment

by:edmund_mitchell
ID: 6461822
Sure.  My email is in my profile - I'll keep an eye out.

Edmund
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6469913
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
 
LVL 2

Author Comment

by:skhorshid
ID: 6470068
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6470325
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
LVL 2

Author Comment

by:skhorshid
ID: 6470406
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
LVL 4

Accepted Solution

by:
edmund_mitchell earned 150 total points
ID: 6471858
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question