First pass at using a schema

C

C.W.Holeman II

I am new to using XML. I am using Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1. In my test I am
attempting to have the style sheet:
http://emle.sourceforge.net/emle020000/emle_lab.xsl transform:
http://emle.sourceforge.net/emle020000/emle_lab_003.xml . The results
display as I expect and look fine to me using the "DOM Inspector". I have
also used CookTop V2.5 to validate the XML and to run the XSLT without
apparent error.

emle_lab_003.xml from above begins:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl"
href="http://emle.sourceforge.net/emle020000/emle_lab.xsl"?>
<emle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="noNamespaceSchemaLocation
http://emle.sourceforge.net/emle020000/emle.xsd">

I expect an error when emle_lab_003.xml does not follow what is defined
in emle.xsd. I have tested this idea by changing "emle" to "emlexxx" in
emle.xsd in this line:

<xsd:element name="emle" type="EmleEmleType"/>

What am I missing?
 
M

Martin Honnen

C.W.Holeman II said:

This either needs to be
xsi:schemaLocation="http://emle.sourceforge.net
http://emle.sourceforge.net/emle020000/emle.xsd"
or

xsi:noNamespaceSchemaLocation="http://emle.sourceforge.net/emle020000/emle.xsd"

In your schema you need to decide what you want to do, if you want to
define elements in the namespace
http://emle.sourceforge.net/emle020000/emle.xsd, then you need to add
elementFormDefault="qualified"
as an attribute on xsd:schema. If you want to define elements in no
namespace then remove the targetNamespace attribute.
 
C

C.W.Holeman II

Martin Honnen said:
This either needs to be
xsi:schemaLocation="http://emle.sourceforge.net
http://emle.sourceforge.net/emle020000/emle.xsd"
or

xsi:noNamespaceSchemaLocation="http://emle.sourceforge.net/emle020000/emle.xsd"

In your schema you need to decide what you want to do,
if you want to define elements in the namespace
http://emle.sourceforge.net/emle020000/emle.xsd, then you need to add
elementFormDefault="qualified"
as an attribute on xsd:schema.
If you want to define elements in no namespace then remove the
targetNamespace attribute.

I want to specify what elements are allowed and to constrain them as
defined in .xsd file. Also, I want to not use namespace prefixes at this
time. So, this is waht I am trying:
In
http://emle.sourceforge.net/emle020000/emle_lab_003_testb.xml:xsi:noNamespaceSchemaLocation="http://emle.sourceforge.net/emle020000/emle_testb.xsd">In
http://emle.sourceforge.net/emle020000/emle_testb.xsd:<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://emle.sourceforge.net">I get the same clean results as before.
Then I again change the main element name from "emle" to "emelxxx" in the
..xsd fileto force whatever kind of error will happen when the elements in my
..xml do notmatch the ones defined in the .xsd file. I expect there to be
some difference but see nochange in behavior.
http://emle.sourceforge.net/emle020...e.sourceforge.net/emle020000/emle_testxxx.xsd
 
C

C.W.Holeman II

I am attempting to undo the mess that the MicroSoft and its newsreader
created
in the posting.

I want to specify what elements are allowed and to constrain them as
defined in .xsd file. Also, I want to not use namespace prefixes at this
time. So, this is what I am trying:

In http://emle.sourceforge.net/emle020000/emle_lab_003_testb.xml :

xsi:noNamespaceSchemaLocation=http://emle.sourceforge.net/emle020000/emle_testb.xsd

In http://emle.sourceforge.net/emle020000/emle_testb.xsd :

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://emle.sourceforge.net">

I get the same clean results as before.

Then I again change the main element name from "emle" to "emelxxx" in the
.xsd file to force whatever kind of error will happen when the elements in
my
.xml do not match the ones defined in the .xsd file. I expect there to be
some difference but see no change in behavior.

http://emle.sourceforge.net/emle020000/emle_lab_003_testxxx.xml

http://emle.sourceforge.net/emle020000/emle_testxxx.xsd


Below the .xml and .xsd file contents have been added:

http://emle.sourceforge.net/emle020000/emle_lab_003_testb.xml:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl"
href="http://emle.sourceforge.net/emle020000/emle_lab.xsl"?>
<emle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://emle.sourceforge.net/emle020000/emle_testb.xsd">
<emleLab emleLNum="3">
<emleLTitle>Rectangle/Fraction (XSLT)</emleLTitle>
<emleEquipment>
<emleETitle>Left Rectangle</emleETitle>
<emleEServer emleESType="EMLE_EST_RECTANGLE" emleWidth="601"
emleHeight="101" />
<emleEControl emleECEnable="properP1Fraction">
<emleECNumerator emleECMin="2" emleECMax="4" emleECStyle="radio"
emleECOrder="ascendingByComponent" />
<emleECDenominator emleECMin="2" emleECMax="4"
emleECStyle="radio" emleECOrder="ascendingByComponent" />
</emleEControl>
</emleEquipment>
<emleEquipment>
<emleETitle>Right Rectangle</emleETitle>
<emleEServer emleESType="EMLE_EST_RECTANGLE" emleWidth="601"
emleHeight="101" />
<emleEControl emleECEnable="properP1Fraction">
<emleECNumerator emleECMin="1" emleECMax="9" emleECStyle="radio"
emleECOrder="ascendingByComponent" />
<emleECDenominator emleECMin="1" emleECMax="9"
emleECStyle="radio" emleECOrder="ascendingByComponent" />
</emleEControl>
</emleEquipment>
<emleLDoc>This is the textual content of the lab "Rectangle/Fraction
(XSLT Test Case)".</emleLDoc>
</emleLab>
</emle>

http://emle.sourceforge.net/emle020000/emle_testb.xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://emle.sourceforge.net">
<xsd:annotation>
<xsd:documentation xml:lang="en">
Electronic Mathematics Labatory Equipment schema for
emle.sourceforge.net.
Copyright 2006. http://emle.sourceforge.net/use.shtml All rights
reserved.
</xsd:documentation>
</xsd:annotation>
<xsd:element name="emle" type="EmleEmleType"/>
<xsd:complexType name="EmleEmleType">
<xsd:sequence>
<xsd:element name="emleLab" type="EmleLabType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="EmleLabType">
<xsd:attribute name="emleLNum" type="xsd:positiveInteger"/>
<xsd:sequence>
<xsd:element name="emlsLTitle" type="xsd:string"/>
<xsd:element name="emleEquipment" type="EmleEquipmentType"/>
<xsd:element name="emleLDoc" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="EmleEquipmentType">
<xsd:sequence>
<xsd:element name="emleETitle" type="xsd:string"/>
<xsd:element name="emleEServer" type="EmleEServerType"/>
<xsd:element name="emleEControl" type="EmleEControlType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="EmleEServerType">
<xsd:attribute name="emleESType" type="EmleESTypeType"/>
<xsd:attribute name="emleWidth" type="xsd:positiveInteger"/>
<xsd:attribute name="emleHeight" type="xsd:positiveInteger"/>
</xsd:complexType>
<xsd:simpleType name="EmleESTypeType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="EMLE_EST_RECTANGLE"/>
<xsd:enumeration value="EMLE_EST_PIE"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="EmleEControlType">
<xsd:attribute name="emleECEnable" type="EmleECEnableType"/>
<xsd:sequence>
<xsd:element name="emleECNumerator" type="EmleECWidgetType"
minOccurs="0"/>
<xsd:element name="emleECDenominator" type="EmleECWidgetType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="EmleECEnableType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="properFraction"/>
<xsd:enumeration value="properP1Fraction"/>
<xsd:enumeration value="improperFraction"/>
<xsd:enumeration value="mixedFraction"/>
<xsd:enumeration value="wholeNumber"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top