PDA

View Full Version : Schema Help


TheJoey
04-04-2010, 12:07 PM
I currently have a schema which using this:
<xs:element name="choose" type="choiceoption"/>
<xs:simpleType name="choiceoption" use="required">
<xs:restriction base="xs:string">
<xs:enumeration value="Choice1"/>
<xs:enumeration value="Choice2"/>
</xs:restriction>
</xs:simpleType>

only problem is i dont know how to apply it to my XML document

<root>

<choose>
ChoiceNotavaible
</choose>

</root>

this parses as correct or is enumeration value for attributes?

thats i just need some clarification and understanding of this.

and what is the proper way to link a schema.

Dormilich
04-04-2010, 04:22 PM
I think the XSD section at w3schools covers that. as far as I remember, you link it in the root element.

TheJoey
04-04-2010, 04:36 PM
i dont think im doing it right, because if i parse my xsd there is errors which i have made.

just to test it.

then when i run it threw the xml it gives me no errors and parses fine

Dormilich
04-04-2010, 04:41 PM
can't tell without full code.

TheJoey
04-04-2010, 04:56 PM
well im thinking its because of my referencing.

thats xsd
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

this is xml
<?xml version="1.0"?>
<medicare xsi:noNamespaceSchemaLocation="xsd.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

Dormilich
04-04-2010, 05:13 PM
where do you test it?

TheJoey
04-04-2010, 05:20 PM
well i test it threw the xml file threw a parser.
ive tested both out.

do you spot anything wrong with my reference?

TheJoey
04-04-2010, 05:27 PM
Could you mabye write me a example of an easy schema and xml how it should look like, im very confused with this.

Dormilich
04-04-2010, 05:29 PM
which parser? does the parser understand XSD?

TheJoey
04-04-2010, 05:34 PM
im assuming yes.

its xerces pparse.

TheJoey
04-05-2010, 02:50 AM
My parser was infact not capable thanks