Solved

MSXML4 - schemas

Posted on 2001-09-05
14
584 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
  • 10
  • 4
14 Comments
 
LVL 4

Expert Comment

by:edmund_mitchell
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 4

Expert Comment

by:edmund_mitchell
Comment Utility
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
Comment Utility
0
 
LVL 2

Author Comment

by:skhorshid
Comment Utility
0
 
LVL 2

Author Comment

by:skhorshid
Comment Utility
testing
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Author Comment

by:skhorshid
Comment Utility
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
Comment Utility
Sure.  My email is in my profile - I'll keep an eye out.

Edmund
0
 
LVL 2

Author Comment

by:skhorshid
Comment Utility
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
Comment Utility
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
LVL 2

Author Comment

by:skhorshid
Comment Utility
sorry for the delay - I have emailed you the files

Thanks in advance

Sherief
0
 
LVL 2

Author Comment

by:skhorshid
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now