Solved

MSXML4 - schemas

Posted on 2001-09-05
14
606 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
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

778 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