all groups > dotnet xml > april 2005 >
You're in the

dotnet xml

group:

XML Schema not working



XML Schema not working Chuck Bowling
4/26/2005 4:14:12 PM
dotnet xml: AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx

I have a Schema (in the link above) that I've been trying to make work in
VS2003 for a while now and just can't seem to get right. I didn't design the
schema and to tell the truth, most of it is beyond my rudimentary
understanding of XML.

So far, the main problem I've run into is the simpleType below:

<simpleType name="VariableName">

<restriction base="string">

<attribute name="name" type="string" />

</restriction>

</simpleType>

I understand that attributes can't be embedded in simpleType's and I'm not
really sure what the attribute is supposed to accomplish anyway. The first
thing I did to try and understand the problem is to remove the attribute. In
an XML file with the AIML targetSchema this led to the error "Undefined
complexType aiml:VariableName is used as a base for complex type
restriction." in the complexType below.

<complexType name="SetVar">

<simpleContent>

<restriction base="aiml:VariableName" />

</simpleContent>

</complexType>

The next step was to convert VariableName to a complexType:

<complexType name="VariableName">

<simpleContent>

<restriction base="string" />

</simpleContent>

</complexType>

This led to the error "Undefined complexType
http://www.we.org/2001/XMLSchema:string is used as a base for complex type
restriction" in VariableName. In a final act of desperation I replaced the
attribute from the original simpleType:

<complexType name="VariableName">

<simpleContent>

<restriction base="string">

<attribute name="name" type="string" />

</restriction>

</simpleContent>

</complexType>

I'm not sure why the attribute was accepted here but it was. However, the
error was the same as above: Undefined complexType string.



Can somebody help me with this thing? It's starting to make me a little
crazy...

Re: XML Schema not working Chris Lovett
4/26/2005 10:52:58 PM

Yes, there are tons of problems with this schema. First you cannot declare
attributes in a simpleType. SimpleTypes are limited to primitive values
only. Looking at the schema I think they really wanted the following:
<complexType name="SetVar">
<attribute name="name" type="string"/>
</complexType>

and
<complexType name="GetVar">
<attribute name="name" type="string"/>
</complexType>

and then I get a different problem which is that on the following you are
not allowed to specify both a name attribute and a ref attribute:

<element name="li" ref="aiml:ConditionItem" maxOccurs="unbounded"/>

This is fixed by changing the ref= to a type=

But then the following "li" element becomes ambiguous, so I would just
delete that, not sure what they were trying to achieve there.

Then you get more errors:
Warning 1 Undefined complexType
'http://alicebot.org/AIMLSchema:PatternExpression' is used as a base for
complex type restriction. C:\temp\AIML.xsd 44 5 Miscellaneous Files
Warning 2 Undefined complexType 'http://www.w3.org/2001/XMLSchema:string' is
used as a base for complex type restriction. C:\temp\AIML.xsd 92 5
Miscellaneous Files

Looks like they are trying to add attributes, so these should be extensions
of simpleType not restrictions, as follows:

<complexType name="If">
<simpleContent>
<extension base="string">
<attribute name="expr" type="aiml:JavaScriptExpression"/>
</extension>
</simpleContent>
</complexType>

and

<complexType name="Pattern">
<simpleContent>
<extension base="aiml:PatternExpression"/>
</simpleContent>
</complexType>

Now it finally compiles cleanly.



[quoted text, click to view]

Re: XML Schema not working Chuck Bowling
4/27/2005 12:44:02 PM
Thanks a lot for your help Chris. I managed to get it to compile down to the
last tag. After which I get this error when I try to derive a new XML file
using the schema:

Undefined data type: PatternExpression.

PatternExpression is defined in line 47...

<simpleType name="PatternExpression">

<restriction base="string">

<minLength value="1" />

<pattern value="(\d|\p{Lu}|\s)+(\*|_)((\d|\p{Lu}|\s)*)" />

<pattern value="(\*|_)((\d|\p{Lu}|\s)*)" />

<pattern value="(\d|\p{Lu}|\s)+" />

</restriction>

</simpleType>


[quoted text, click to view]

AddThis Social Bookmark Button