Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   First pass at using a schema (http://www.velocityreviews.com/forums/t392681-first-pass-at-using-a-schema.html)

C.W.Holeman II 01-03-2007 11:46 PM

First pass at using a schema
 
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?

--
C.W.Holeman II | cwhii@Julian5Locals.com -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




Martin Honnen 01-04-2007 01:06 PM

Re: First pass at using a schema
 
C.W.Holeman II wrote:

> <emle xmlns:xsi="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/

C.W.Holeman II 01-04-2007 07:01 PM

Re: First pass at using a schema
 
"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:459cfbbd$0$5711$9b4e6d93@newsspool3.arcor-online.net...
> C.W.Holeman II wrote:
>
>> <emle xmlns:xsi="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.xml:xsi:noNamespaceSchemaLocati on="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/emle0200...le_testxxx.xsd



C.W.Holeman II 01-04-2007 11:52 PM

Re: First pass at using a schema
 
I am attempting to undo the mess that the MicroSoft and its newsreader
created
in the posting.

> "Martin Honnen" <mahotrash@yahoo.de> wrote in message
> news:459cfbbd$0$5711$9b4e6d93@newsspool3.arcor-online.net...
>> C.W.Holeman II wrote:
>>
>>> <emle xmlns:xsi="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 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/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 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>

--
C.W.Holeman II | cwhii@Julian5Locals.com -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




All times are GMT. The time now is 05:38 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.