Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > First pass at using a schema

Reply
Thread Tools

First pass at using a schema

 
 
C.W.Holeman II
Guest
Posts: n/a
 
      01-03-2007
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 xmlnssi="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?

--
C.W.Holeman II | -5 | http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks



 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-04-2007
C.W.Holeman II wrote:

> <emle xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="noNamespaceSchemaLocation
> http://emle.sourceforge.net/emle020000/emle.xsd">


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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
C.W.Holeman II
Guest
Posts: n/a
 
      01-04-2007
"Martin Honnen" <> wrote in message
news:459cfbbd$0$5711$...
> C.W.Holeman II wrote:
>
>> <emle xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="noNamespaceSchemaLocation
>> http://emle.sourceforge.net/emle020000/emle.xsd">

>
> 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.xmlsi:noNamespaceSchemaLocati on="http://emle.sourceforge.net/emle020000/emle_testb.xsd">In
http://emle.sourceforge.net/emle020000/emle_testb.xsd:<xsd:schema
xmlnssd="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/emle0200...le_testxxx.xsd


 
Reply With Quote
 
C.W.Holeman II
Guest
Posts: n/a
 
      01-04-2007
I am attempting to undo the mess that the MicroSoft and its newsreader
created
in the posting.

> "Martin Honnen" <> wrote in message
> news:459cfbbd$0$5711$...
>> C.W.Holeman II wrote:
>>
>>> <emle xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="noNamespaceSchemaLocation
>>> http://emle.sourceforge.net/emle020000/emle.xsd">

>>
>> 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 what I am trying:

In http://emle.sourceforge.net/emle0200..._003_testb.xml :

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

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

<xsd:schema xmlnssd="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/emle0200...03_testxxx.xml

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


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

http://emle.sourceforge.net/emle0200...003_testb.xml:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl"
href="http://emle.sourceforge.net/emle020000/emle_lab.xsl"?>
<emle xmlnssi="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 xmlnssd="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="xsdositiveInteger"/>
<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="xsdositiveInteger"/>
<xsd:attribute name="emleHeight" type="xsdositiveInteger"/>
</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>

--
C.W.Holeman II | -5 | http://JulianLocals.com/cwhii
To only a fraction of the human race does God give the privilege of
earning one's bread doing what one would have gladly pursued free, for
passion. I am very thankful. The Mythical Man-Month Epilogue/F.P.Brooks


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation with XSD using XML::LibXML::Schema, and XML::Validator::Schema huntingseasonson@gmail.com Perl Misc 5 11-29-2006 12:37 PM
Problem with schema-validation and property "http://apache.org/xml/properties/schema/external-schemaLocation" Markus Java 1 11-23-2005 02:41 PM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Schema Metadata not a Metadata Schema Brett Selleck XML 1 09-04-2003 05:02 PM
Re: Convert DB2 schema to XML Schema Klaus Johannes Rusch XML 0 08-06-2003 11:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57